Libraryless. Click here for Pure Java version (1527L/10K/38K).
1 | !7 |
2 | |
3 | static Lock a = fairLock(); |
4 | static Lock b = fairLock(); |
5 | |
6 | p-tt { |
7 | centerHigherConsole(); |
8 | startDeadlockDetector(); |
9 | print("Initiating deadlock... :-)\n"); |
10 | |
11 | thread "A" { |
12 | a.lock(); |
13 | try { |
14 | print("Thread A has lock A."); |
15 | sleep1Second(); |
16 | print("Thread A getting lock B."); |
17 | b.lock(); |
18 | try { |
19 | print("Thread A sleeping."); |
20 | main.sleep(); |
21 | } finally { |
22 | b.unlock(); |
23 | } |
24 | } finally { |
25 | a.unlock(); |
26 | } |
27 | } |
28 | |
29 | thread "B" { |
30 | b.lock(); |
31 | try { |
32 | print("Thread B has lock B."); |
33 | sleep1Second(); |
34 | print("Thread B getting lock A."); |
35 | a.lock(); |
36 | try { |
37 | print("Thread B sleeping."); |
38 | main.sleep(); |
39 | } finally { |
40 | a.unlock(); |
41 | } |
42 | } finally { |
43 | b.unlock(); |
44 | } |
45 | } |
46 | |
47 | sleepQuietly(); |
48 | } |
Began life as a copy of #1009280
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: | #1009311 |
Snippet name: | Java DeadLock Detection Test with ReentrantLock [WORKS] |
Eternal ID of this version: | #1009311/2 |
Text MD5: | 701672e56082106851242d071d83a3ba |
Transpilation MD5: | 63d5507c778ddb392c58785564fb8b7f |
Author: | stefan |
Category: | javax |
Type: | JavaX source code |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2017-07-23 15:13:46 |
Source code size: | 869 bytes / 48 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 454 / 534 |
Version history: | 1 change(s) |
Referenced in: | [show references] |