title: Android finding a deadlock
body: <p>I am getting an ANR sometimes when I run my Android service. I suspect it is happening because of a deadlock. </p>
  
  <p>Is there an easy way to monitor deadlock in Android or Eclipse. Such as a utility to show which thread hold which lock etc.?</p>
  
  <p>And is there a way to figure out a deadlock by looking at traces.txt file?</p>
  
  <p>My ddms log looks like this at the time of crash</p>
  
  <pre><code>02-15 18:09:01.046: INFO/Process(90): Sending signal. PID: 450 SIG: 3
  02-15 18:09:01.046: INFO/dalvikvm(450): threadid=3: reacting to signal 3
  02-15 18:09:01.056: INFO/dalvikvm(450): Wrote stack traces to '/data/anr/traces.txt'
  02-15 18:09:01.076: INFO/Process(90): Sending signal. PID: 10548 SIG: 9
  02-15 18:09:01.076: ERROR/ActivityManager(90): ANR in com.abc.cm.core
  02-15 18:09:01.076: ERROR/ActivityManager(90): Reason: Executing service com.abc.cm.core/.WorkOrderManager
  02-15 18:09:01.076: ERROR/ActivityManager(90): Load: 1.46 / 1.16 / 1.05
  02-15 18:09:01.076: ERROR/ActivityManager(90): CPU usage from 19462ms to 1067ms ago:
  02-15 18:09:01.076: ERROR/ActivityManager(90):   abc.cm.core: 13% = 12% user + 1% kernel / faults: 1360 minor
  02-15 18:09:01.076: ERROR/ActivityManager(90):   mmcqd: 4% = 0% user + 4% kernel
  02-15 18:09:01.076: ERROR/ActivityManager(90):   system_server: 3% = 2% user + 1% kernel / faults: 473 minor
  02-15 18:09:01.076: ERROR/ActivityManager(90):   zygote: 2% = 2% user + 0% kernel / faults: 90 minor
  02-15 18:09:01.076: ERROR/ActivityManager(90):   adbd: 1% = 0% user + 1% kernel / faults: 1042 minor
  02-15 18:09:01.076: ERROR/ActivityManager(90):   m.abc.unten: 0% = 0% user + 0% kernel / faults: 203 minor
  02-15 18:09:01.076: ERROR/ActivityManager(90):   ndroid.launcher: 0% = 0% user + 0% kernel / faults: 802 minor
  02-15 18:09:01.076: ERROR/ActivityManager(90):   droid.wallpaper: 0% = 0% user + 0% kernel / faults: 109 minor
  02-15 18:09:01.076: ERROR/ActivityManager(90):   ndroid.settings: 0% = 0% user + 0% kernel / faults: 44 minor
  02-15 18:09:01.076: ERROR/ActivityManager(90):   dhd_dpc: 0% = 0% user + 0% kernel
  02-15 18:09:01.076: ERROR/ActivityManager(90):   events/0: 0% = 0% user + 0% kernel
  02-15 18:09:01.076: ERROR/ActivityManager(90):   logcat: 0% = 0% user + 0% kernel
  02-15 18:09:01.076: ERROR/ActivityManager(90):  +andisk.api.test: 0% = 0% user + 0% kernel
  02-15 18:09:01.076: ERROR/ActivityManager(90):  +iTestFwService1: 0% = 0% user + 0% kernel
  02-15 18:09:01.076: ERROR/ActivityManager(90):  +sh: 0% = 0% user + 0% kernel
  02-15 18:09:01.076: ERROR/ActivityManager(90): TOTAL: 40% = 23% user + 16% kernel + 0% iowait + 0% softirq
  02-15 18:09:01.096: INFO/ActivityManager(90): Process com.abc.cm.core (pid 10548) has died.
  </code></pre>