Libraryless. Click here for Pure Java version (14735L/102K).
!7 module ThreadComparison > DynSingleFunction { int multiplicity = 4; void doIt { print("Benchmarking..."); final long endTime = sysTimePlus(5000); final new L<AtomicLong> counts; new L<Thread> threads; repeat multiplicity { final AtomicLong c = addAndReturn(counts, new AtomicLong); threads.add(minPriorityThread(r { while (sysNow() < endTime) incAtomicLong(c) })); } repeat multiplicity { final AtomicLong c = addAndReturn(counts, new AtomicLong); threads.add(maxPriorityThread(r { while (sysNow() < endTime) incAtomicLong(c) })); } joinThreads(threads); for i over threads: print("Count " + (i+1) + " [priority " + threads.get(i).getPriority() + "]: " + counts.get(i)); } visualize { ret northAndCenter(vstackWithSpacing( withLabel("Multiplicity:", liveValueSpinner(dm_fieldLiveValue('multiplicity), 1, 32)), super.visualize()), dm_printLogComponent()); } }
download show line numbers debug dex old transpilations
Travelled to 13 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, irmadwmeruwu, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, vouqrxazstgt
No comments. add comment
Snippet ID: | #1018831 |
Snippet name: | Thread Comparison: Max Priority vs Min Priority |
Eternal ID of this version: | #1018831/14 |
Text MD5: | e68c376a6974b5bba3b680ad4c1452d1 |
Transpilation MD5: | 101e2cbee3deb7165502b324a0b0b848 |
Author: | stefan |
Category: | javax |
Type: | JavaX source code (Dynamic Module) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2018-10-14 01:03:03 |
Source code size: | 998 bytes / 30 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 405 / 513 |
Version history: | 13 change(s) |
Referenced in: | -