Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What are the Dalvik thread states?

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...

like image 347
Barry Fruitman Avatar asked Apr 21 '14 22:04

Barry Fruitman


1 Answers

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".)
like image 114
fadden Avatar answered Nov 15 '22 19:11

fadden