TestRunnable[] synced = new TestRunnable[threads];
for (int t = 0; t < threads; t++) {
synced[t] = new SynchedWorker(stream);
}
MultiThreadedTestRunner syncedrunner = new MultiThreadedTestRunner(synced);
// kickstarts the MTTR & fires off threads
long start = System.nanoTime();
try {
syncedrunner.runTestRunnables();
} catch (Throwable e) {
log.warn("Exception {}", e);
fail();
}
System.out.println("Runtime for synced runner: " + (System.nanoTime() - start) + "ns");
// test unsynchronized
name = "non-synchronized";
NoSyncServerStream nstream = new NoSyncServerStream();
nstream.setName(name);
nstream.setPublishedName(name);
// pass that instance to the MTTR
TestRunnable[] unsynced = new TestRunnable[threads];
for (int t = 0; t < threads; t++) {
unsynced[t] = new UnSynchedWorker(nstream);
}
MultiThreadedTestRunner unsyncedrunner = new MultiThreadedTestRunner(unsynced);
// kickstarts the MTTR & fires off threads
start = System.nanoTime();
try {
unsyncedrunner.runTestRunnables();
} catch (Throwable e) {
log.warn("Exception {}", e);
fail();
}
System.out.println("Runtime for unsynced runner: " + (System.nanoTime() - start) + "ns");