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

18
LINES

< > BotCompany Repo | #1009295 // printDeadlocks_monitorsOnly - print list of deadlocked threads (counting only object monitor deadlocks); returns the list of deadlocked ThreadInfo objects

JavaX fragment (include)

1  
static L<ThreadInfo> printDeadlocks_monitorsOnly() {
2  
  ThreadMXBean bean = ManagementFactory.getThreadMXBean();
3  
  long ids[] = bean.findMonitorDeadlockedThreads();
4  
  if (empty(ids)) ret emptyList();
5  
  
6  
  printAsciiHeading("DEADLOCKED THREADS!");
7  
  ThreadInfo threadInfo[] = bean.getThreadInfo(ids);
8  
  int i = 0;
9  
  for (ThreadInfo threadInfo1 : threadInfo) {
10  
    print("Thread " + (++i) + "/" + l(threadInfo) + ": ID=" + threadInfo1.getThreadId()
11  
      + ", name=" + quote(threadInfo1.getThreadName()));
12  
    print("  Trying to lock: " + threadInfo1.getLockName()
13  
      + " which is owned by thread " + threadInfo1.getLockOwnerId()
14  
      + " (" + quote(threadInfo1.getLockOwnerName()) + ")");
15  
  }
16  
  print();
17  
  ret asList(threadInfo);
18  
}

Author comment

Began life as a copy of #1009292

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: #1009295
Snippet name: printDeadlocks_monitorsOnly - print list of deadlocked threads (counting only object monitor deadlocks); returns the list of deadlocked ThreadInfo objects
Eternal ID of this version: #1009295/3
Text MD5: abeb7188ddf75f63f3ebc6325c23c279
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2017-07-21 16:45:02
Source code size: 750 bytes / 18 lines
Pitched / IR pitched: No / No
Views / Downloads: 376 / 400
Version history: 2 change(s)
Referenced in: [show references]