title: How to detect deadlocks programmatically in Android?
body: <p>I know and used the resource available <a href="http://javaconceptoftheday.com/detect-deadlocked-threads-using-threadmxbean-class-java/" rel="nofollow noreferrer">here</a> to detect deadlocks programmatically in Java.</p>
  
  <pre><code>  ThreadMXBean bean = ManagementFactory.getThreadMXBean();
  
      long ids[] = bean.findMonitorDeadlockedThreads();
  
      if(ids != null)
      {
          ThreadInfo threadInfo[] = bean.getThreadInfo(ids);
  
          for (ThreadInfo threadInfo1 : threadInfo)
          {
              System.out.println(threadInfo1.getThreadId());    //Prints the ID of deadlocked thread
  
              System.out.println(threadInfo1.getThreadName());  //Prints the name of deadlocked thread
  
              System.out.println(threadInfo1.getLockName());    //Prints the string representation of an object for which thread has entered into deadlock.
  
              System.out.println(threadInfo1.getLockOwnerId());  //Prints the ID of thread which currently owns the object lock
  
              System.out.println(threadInfo1.getLockOwnerName());  //Prints name of the thread which currently owns the object lock.
          }
      }
      else
      {
          System.out.println("No Deadlocked Threads");
      }
  </code></pre>
  
  <p>The code above determines and prints the deadlocked thread and related information. I tried the same in Android Studio and found that android doesn't support this. Is there an equivalent to that in android?</p>