Download Jar. Libraryless. Click here for Pure Java version (1041L/7K).
!7 sclass BetterThreadLocal<A> { Map<Thread, A> map = newWeakHashMap(); A get() { ret map.get(currentThread()); } void set(A a) { mapPutOrRemove(map, currentThread(), a); } } static new BetterThreadLocal<S> tl; p { assertNull(tl!); tl.set("hello"); assertEq("hello", tl!); startAndJoinThread(r { assertNull(tl!); }); tl.set(null); assertNull(tl!); }
download show line numbers debug dex old transpilations
Travelled to 13 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt
No comments. add comment
Snippet ID: | #1011380 |
Snippet name: | ThreadLocal Alternative [OK] |
Eternal ID of this version: | #1011380/4 |
Text MD5: | 4e8512cbe685ea1f4421be63129fa90e |
Transpilation MD5: | c8cf3f959d030e2277b6e674497f3ba3 |
Author: | stefan |
Category: | javax |
Type: | JavaX source code (desktop) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2017-10-26 08:14:48 |
Source code size: | 419 bytes / 26 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 656 / 1394 |
Version history: | 3 change(s) |
Referenced in: | [show references] |