如何在 Android 中以编程方式检测死锁?

How to detect deadlocks programmatically in Android?

我知道并使用可用资源 here 以编程方式检测 Java 中的死锁。

  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");
    }

以上代码判断并打印死锁线程及相关信息。我在 Android Studio 中尝试了同样的方法,发现 android 不支持这个。 android中是否有等价物?

ThreadMXBean 不是 Android 框架的一部分。这个问题已经出现在这里 Android finding a deadlock