Libraryless. Click here for Pure Java version (4578L/26K).
// 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)); }
download show line numbers debug dex old transpilations
Travelled to 3 computer(s): bhatertpkbcr, mowyntqkapby, mqqgnosmbjvj
No comments. add comment
Snippet ID: | #1032605 |
Snippet name: | testThreadCancellation |
Eternal ID of this version: | #1032605/7 |
Text MD5: | 7cf48e40ffcd415a66ededf49c9ad8ea |
Transpilation MD5: | ffac00bc17fcddc297302aa1b0ee6b2b |
Author: | stefan |
Category: | javax |
Type: | JavaX fragment (include) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2021-09-24 22:09:50 |
Source code size: | 724 bytes / 23 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 142 / 213 |
Version history: | 6 change(s) |
Referenced in: | #1006654 - Standard functions list 2 (LIVE, continuation of #761) |