Not logged in.  Login/Logout/Register | List snippets | | Create snippet | Upload image | Upload data

36
LINES

< > BotCompany Repo | #1009280 // Java DeadLock Detection Test :) [WORKS]

JavaX source code [tags: use-pretranspiled] - run with: x30.jar

Libraryless. Click here for Pure Java version (1512L/10K/38K).

!7

static new O a;
static new O b;

p-tt {
  centerHigherConsole();
  startDeadlockDetector();
  print("Initiating deadlock... :-)\n");
  
  thread "A" {
    synchronized(a) {
      print("Thread A has lock A.");
      sleep1Second();
      print("Thread A getting lock B.");
      synchronized(b) {
        print("Thread A sleeping.");
        main.sleep();
      }
    }
  }
  
  thread "B" {
    synchronized(b) {
      print("Thread B has lock B.");
      sleep1Second();
      print("Thread B getting lock A.");
      synchronized(a) {
        print("Thread B sleeping.");
        main.sleep();
      }
    }
  }
  
  sleepQuietly();
}

download  show line numbers  debug dex  old transpilations   

Travelled to 15 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, onxytkatvevr, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt, wtqryiryparv

No comments. add comment

Snippet ID: #1009280
Snippet name: Java DeadLock Detection Test :) [WORKS]
Eternal ID of this version: #1009280/11
Text MD5: effc0c1ab38c8efbd4c8562c84412a69
Transpilation MD5: 1745d33e491e18d836722d6f50d26454
Author: stefan
Category: javax
Type: JavaX source code
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2017-07-23 02:17:43
Source code size: 676 bytes / 36 lines
Pitched / IR pitched: No / No
Views / Downloads: 477 / 653
Version history: 10 change(s)
Referenced in: #1009302 - Try to solve deadlock by interrupting threads [doesn't work]
#1009311 - Java DeadLock Detection Test with ReentrantLock [WORKS]