12

Every ANR dump lists the states of all threads at the time of the ANR. I know what WAIT means but what do SUSPENDED and MONITOR mean?

Thanks in advance...

Barry Fruitman
  • 12,316
  • 13
  • 72
  • 135

1 Answers1

39

Summary of Dalvik thread states:

  • INITIALIZING - not yet running.
  • STARTING - not yet running, but almost there.
  • ZOMBIE - deceased (you shouldn't see this).
  • RUNNING (a/k/a RUNNABLE) - thread is actively running. The VM has to suspend all threads to do the stack dump, so you generally won't see this for any thread other than the one that is dumping the stack.
  • WAIT - the thread called wait(), and is patiently waiting.
  • TIMED_WAIT - thread called wait(), with a timeout. (Thread.sleep() is implemented as a timed wait.)
  • MONITOR - thread is blocked on a monitor lock, i.e. it's stuck trying to enter a "synchronized" block.
  • NATIVE - thread is executing in native code. The VM doesn't suspend threads in native code unless they make a JNI call (at which point they transition to RUNNING, and then immediately to SUSPENDED).
  • VMWAIT - thread is blocked acquiring a VM resource, like an internal mutex. Or maybe waiting for something to do (e.g. the Compiler and GC threads).
  • SUSPENDED - thread was runnable, but has been suspended. As noted earlier, the stack dumper likes to suspend all threads before traversing their stacks, so your busy threads will generally show up this way. (In older releases, this state did not exist; "suspended" used to be "RUNNING with a nonzero sCount".)
fadden
  • 51,356
  • 5
  • 116
  • 166
  • 1
    Great answer, thank you. I wish I could give it TWO checkmarks! – Barry Fruitman Apr 21 '14 at 23:19
  • Excellent,i get them now – snowdream Mar 19 '15 at 10:17
  • "RUNNING (a/k/a RUNNABLE) - thread is actively running. The VM has to suspend all threads to do the stack dump, so you generally won't see this for any thread other than the one that is dumping the stack. " I do not understand this, Which thread state won't I see, RUNNABLE or RUNNING? – dragonfly Jun 03 '15 at 09:29
  • 1
    The names reference a single state. The internal constant and the value shown by JDWP debuggers is "RUNNING", but the thread dump code prints "RUNNABLE". "a/k/a" means "also known as", and indicates that one name is an alias of the other. – fadden Jun 03 '15 at 16:07