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