assertTrue(app.createChildScope("mt"));
room = ScopeUtils.resolveScope(appScope, "/junit/mt");
}
// create the SO
assertTrue(app.createSharedObject(room, "mtSO", persistent));
ISharedObject so = app.getSharedObject(room, "mtSO");
// acquire only works with non-persistent so's
if (!persistent) {
so.acquire();
assertTrue(so.isAcquired());
}
// test runnables represent clients
trs = new TestRunnable[21];
for (int t = 0; t < trs.length; t++) {
trs[t] = new ScopeClientWorker(t, app, room);
}
MultiThreadedTestRunner mttr = new MultiThreadedTestRunner(trs);
// fires off threads
long start = System.nanoTime();
mttr.runTestRunnables();
System.out.println("Runtime: " + (System.nanoTime() - start) + "ns");
// go to sleep
try {
Thread.sleep(3000);
} catch (Exception e) {
}
for (TestRunnable r : trs) {
ScopeClientWorker cl = (ScopeClientWorker) r;
log.debug("Worker: {} shared object: {}", cl.getId(), cl.getSharedObject().getAttributes());
}
if (!persistent) {
assertTrue(so.isAcquired());
so.release();
assertFalse(so.isAcquired());
}
app.stop(appScope);
// IScope room1 = ScopeUtils.resolveScope(appScope, "/junit/room1");
// IScope room4 = ScopeUtils.resolveScope(appScope, "/junit/room1/room4");