Libraryless. Click here for Pure Java version (3870L/22K).
1 | // a variant of thread where you can get the Runnable target later. |
2 | // Also notes its existence on the VM bus. |
3 | // We should use this exclusively instead of Thread. |
4 | |
5 | sclass BetterThread extends Thread { |
6 | Runnable target; |
7 | |
8 | *(Runnable *target) { _created(); } |
9 | *(Runnable *target, S name) { super(name); _created(); } |
10 | |
11 | void _created() { vmBus_send threadCreated(this); } |
12 | |
13 | run { |
14 | try { |
15 | vmBus_send threadStarted(this); |
16 | if (target != null) target.run(); |
17 | } finally { |
18 | vmBus_send threadEnded(this); |
19 | } |
20 | } |
21 | |
22 | Runnable getTarget() { ret target; } |
23 | } |
download show line numbers debug dex old transpilations
Travelled to 6 computer(s): bhatertpkbcr, ekrmjmnbrukm, mowyntqkapby, mqqgnosmbjvj, pyentgdyhuwx, vouqrxazstgt
No comments. add comment
Snippet ID: | #1031672 |
Snippet name: | BetterThread |
Eternal ID of this version: | #1031672/7 |
Text MD5: | ae3c430e60869b90ce26212cf6fa54f0 |
Transpilation MD5: | c34cdea33517208967920723da9e4cde |
Author: | stefan |
Category: | javax |
Type: | JavaX fragment (include) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2021-06-26 19:47:08 |
Source code size: | 605 bytes / 23 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 210 / 446 |
Version history: | 6 change(s) |
Referenced in: | [show references] |