2017-02-15 3 views
-1

Java에서 프로그래밍 방식으로 교착 상태를 감지하기 위해 here 리소스를 알고 있고 사용했습니다.Android에서 프로그래밍 방식으로 교착 상태를 감지하는 방법은 무엇입니까?

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가 이것을 지원하지 않는다는 것을 알았습니다. 거기 안드로이드에 해당하는가요?

답변

2

ThreadMXBean은 Android 프레임 워크에 포함되어 있지 않습니다. 이 질문은 이미 여기에 있습니다. Android finding a deadlock

+0

쉬운 방법은 없습니다! 고마워요! 나는 많은 것을 봤지만, 이것에 대한 해결책을 찾지 못했습니다. 이제 그 이유를 알았습니다. – Feruchemist947