Libraryless. Click here for Pure Java version (1536L/11K/39K).
!7 static Lock a = fairLock(); static Lock b = fairLock(); static int timeout = 10000; p-tt { centerHigherConsole(); startDeadlockDetector_noStop = true; startDeadlockDetector(); print("Initiating deadlock with timeout " + timeout + " ms... :-)\n"); thread "A" { lockOrFail(a, timeout); try { print("Thread A has lock A."); sleep1Second(); print("Thread A getting lock B."); lockOrFail(b, timeout); try { print("Thread A successful!"); } finally { b.unlock(); } } finally { a.unlock(); } } thread "B" { lockOrFail(b, timeout); try { print("Thread B has lock B."); sleep1Second(); print("Thread B getting lock A."); lockOrFail(a, timeout); try { print("Thread B successful!"); } finally { a.unlock(); } } finally { b.unlock(); } } sleepQuietly(); }
Began life as a copy of #1009311
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: | #1009312 |
Snippet name: | Java DeadLock Timeout Test with ReentrantLock [WORKS, but usually both threads fail] |
Eternal ID of this version: | #1009312/5 |
Text MD5: | 1c7118608cd9e767cfe42d075d5a322a |
Transpilation MD5: | d2f06cfde8db86b887eaf6c423aaedc4 |
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:21:35 |
Source code size: | 982 bytes / 48 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 563 / 639 |
Version history: | 4 change(s) |
Referenced in: | -