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

29
LINES

< > BotCompany Repo | #1009356 // Java New DeadLock Test (should now be solved by JavaX core automatically!)

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

Libraryless. Click here for Pure Java version (1344L/9K/33K).

!7

static Lock a = fairLock();
static Lock b = fairLock();

p-tt {
  centerHigherConsole();
  print("Initiating deadlock... :-)\n");
  
  thread "A" {
    lock a; // cool new syntax!
    print("Thread A has lock A.");
    sleep1Second();
    print("Thread A getting lock B.");
    lock b;
    print("Thread A successful!");
  }
  
  thread "B" {
    lock b ;
    print("Thread B has lock B.");
    sleep1Second();
    print("Thread B getting lock A.");
    lock a;
    print("Thread B successful!");
  }
  
  sleepQuietly();
}

Author comment

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: #1009356
Snippet name: Java New DeadLock Test (should now be solved by JavaX core automatically!)
Eternal ID of this version: #1009356/3
Text MD5: a05c4b480a1d97c934c5121b7b44d99a
Transpilation MD5: 5d0a91c900bd06aaa86e5a50510d87e7
Author: stefan
Category: javax
Type: JavaX source code
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2017-07-24 17:00:00
Source code size: 555 bytes / 29 lines
Pitched / IR pitched: No / No
Views / Downloads: 394 / 475
Version history: 2 change(s)
Referenced in: [show references]