Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
549 views
in Technique[技术] by (71.8m points)

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

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...