Пример #1
0
 /**
  * Formats the thread dump for one thread.
  *
  * @param ti the ThreadInfo describing the thread
  * @return the formatted thread dump
  */
 private static String getThreadDump(ThreadInfo ti) {
   StringBuilder sb = new StringBuilder(getThreadDumpHeader(ti));
   for (LockInfo li : ti.getLockedSynchronizers()) {
     sb.append(INDENT2 + "locks " + li.toString() + CRLF);
   }
   boolean start = true;
   StackTraceElement[] stes = ti.getStackTrace();
   Object[] monitorDepths = new Object[stes.length];
   MonitorInfo[] mis = ti.getLockedMonitors();
   for (int i = 0; i < mis.length; i++) {
     monitorDepths[mis[i].getLockedStackDepth()] = mis[i];
   }
   for (int i = 0; i < stes.length; i++) {
     StackTraceElement ste = stes[i];
     sb.append(INDENT2 + "at " + ste.toString() + CRLF);
     if (start) {
       if (ti.getLockName() != null) {
         sb.append(INDENT2 + "- waiting on (a " + ti.getLockName() + ")");
         if (ti.getLockOwnerName() != null) {
           sb.append(" owned by " + ti.getLockOwnerName() + " Id=" + ti.getLockOwnerId());
         }
         sb.append(CRLF);
       }
       start = false;
     }
     if (monitorDepths[i] != null) {
       MonitorInfo mi = (MonitorInfo) monitorDepths[i];
       sb.append(
           INDENT2
               + "- locked (a "
               + mi.toString()
               + ")"
               + " index "
               + mi.getLockedStackDepth()
               + " frame "
               + mi.getLockedStackFrame().toString());
       sb.append(CRLF);
     }
   }
   return sb.toString();
 }
Пример #2
0
 public boolean heldReadsContains(LockInfo lockInfo) {
   return holdingReads.containsKey(lockInfo.toString());
 }
Пример #3
0
 public boolean heldWritesContains(LockInfo lockInfo) {
   return holdingWrites.containsKey(lockInfo.toString());
 }
Пример #4
0
 public boolean isWaitingFor(WaitingFor waitingFor, LockInfo waitingForLock) {
   return this.waitingFor == waitingFor
       && this.waitingForLock != null
       && this.waitingForLock.toString().equals(waitingForLock.toString());
 }
Пример #5
0
 void addHoldingRead(LockInfo lockInfo) {
   this.holdingReads.put(lockInfo.toString(), lockInfo);
 }
Пример #6
0
 void addHoldingWrite(LockInfo lockInfo) {
   this.holdingWrites.put(lockInfo.toString(), lockInfo);
 }