// this assures that cancelling threads made in the same realm works. // for cancelling across realms, another test would be needed. svoid testThreadCancellation(double extraSleep default 0) { new Flag flag1; new Flag flag2; Thread t = startThread("testThreadCancellation", r { flag1.raise(); try { busySleepSeconds(20.0); } finally { flag2.raise(); } }); flag1.waitUntilUp(); sleepSeconds(extraSleep); assertFalse(flag2.isUp()); long time = nanoTime(); cancelThread(t); assertTrue("Thread cancellation works", flag2.waitUntilUp(2.0)); time = nanoTime()-time; print("Local thread cancellation works. Took " + renderElapsedNanosPleasantly(time)); }