Libraryless. Click here for Pure Java version (14693L/101K).
1 | !7 |
2 | |
3 | sclass ProvokeDeadLock > DynPrintLog { |
4 | transient Lock a = fairLock(); |
5 | transient Lock b = fairLock(); |
6 | |
7 | JComponent visualize() { |
8 | ret withCenteredButtons(super.visualize(), |
9 | "Do the deadlock", rThread doIt); |
10 | } |
11 | |
12 | void doIt { |
13 | temp dm_tempDisableAllButtons(); |
14 | |
15 | print("Initiating deadlock... :-)\n"); |
16 | |
17 | Thread threadA = startThread("A", r { |
18 | lock a; // cool new syntax! |
19 | print("Thread A has lock A."); |
20 | sleep1Second(); |
21 | print("Thread A getting lock B."); |
22 | lock b; |
23 | print("Thread A successful!"); |
24 | }); |
25 | |
26 | Thread threadB = startThread("B", r { |
27 | lock b; |
28 | print("Thread B has lock B."); |
29 | sleep1Second(); |
30 | print("Thread B getting lock A."); |
31 | lock a; |
32 | print("Thread B successful!"); |
33 | }); |
34 | |
35 | joinThreads(threadA, threadB); |
36 | setModuleName(print("Deadlock solved!")); |
37 | } |
38 | } |
Began life as a copy of #1009356
download show line numbers debug dex old transpilations
Travelled to 14 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, irmadwmeruwu, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt
No comments. add comment
Snippet ID: | #1016805 |
Snippet name: | Provoke DeadLock (& have OS solve it) [Dyn Module] |
Eternal ID of this version: | #1016805/9 |
Text MD5: | 3e7c509cbae334e42ea95e7b3ce16d3b |
Transpilation MD5: | 3f302aacbac6a78fd6d39b4fee02f53c |
Author: | stefan |
Category: | javax |
Type: | JavaX source code (Dynamic Module) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2018-07-03 00:12:02 |
Source code size: | 918 bytes / 38 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 604 / 759 |
Version history: | 8 change(s) |
Referenced in: | [show references] |