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)

static L<ThreadInfo> printDeadlocks_monitorsOnly() {
  ThreadMXBean bean = ManagementFactory.getThreadMXBean();
  long ids[] = bean.findMonitorDeadlockedThreads();
  if (empty(ids)) ret emptyList();
  
  printAsciiHeading("DEADLOCKED THREADS!");
  ThreadInfo threadInfo[] = bean.getThreadInfo(ids);
  int i = 0;
  for (ThreadInfo threadInfo1 : threadInfo) {
    print("Thread " + (++i) + "/" + l(threadInfo) + ": ID=" + threadInfo1.getThreadId()
      + ", name=" + quote(threadInfo1.getThreadName()));
    print("  Trying to lock: " + threadInfo1.getLockName()
      + " which is owned by thread " + threadInfo1.getLockOwnerId()
      + " (" + quote(threadInfo1.getLockOwnerName()) + ")");
  }
  print();
  ret asList(threadInfo);
}

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: 372 / 397
Version history: 2 change(s)
Referenced in: [show references]