Libraryless. Click here for Pure Java version (2581L/16K).
sclass FlexThreadLocal<A> extends BetterThreadLocal<A> { static Map<Thread> motherThreads = weakMap(); public A get() { ret get(grandMotherThread()); } void set(A a) { map.put(grandMotherThread(), a); } static Thread grandMotherThread(Thread t default currentThread()) { ret applyWhileNotNull motherThread(t); } static void setMotherThread(Thread t) { mapPutOrRemove(motherThreads, currentThread(), grandMotherThread(t)); } static Thread motherThread(Thread t default currentThread()) { ret mapGet(motherThreads, t); } }
download show line numbers debug dex old transpilations
Travelled to 4 computer(s): bhatertpkbcr, mqqgnosmbjvj, pyentgdyhuwx, vouqrxazstgt
No comments. add comment
| Snippet ID: | #1030297 |
| Snippet name: | FlexThreadLocal - more flexible version of BetterThreadLocal [for inheriting threadlocals in thread pools] |
| Eternal ID of this version: | #1030297/6 |
| Text MD5: | eaa608a71e198a9db416aaef607a408d |
| Transpilation MD5: | f45a82375bf73bbf8c9d1e99d5b7a832 |
| Author: | stefan |
| Category: | javax / threads |
| Type: | JavaX fragment (include) |
| Public (visible to everyone): | Yes |
| Archived (hidden from active list): | No |
| Created/modified: | 2020-11-28 00:05:28 |
| Source code size: | 597 bytes / 23 lines |
| Pitched / IR pitched: | No / No |
| Views / Downloads: | 452 / 782 |
| Version history: | 5 change(s) |
| Referenced in: | [show references] |