问题描述
- 用jstack看到的WAITING和BLOCK的区别的是什么
-
用jstack看到的WAITING和BLOCK的区别的是什么
解决方案
打开eclipse查看JDK的源码,类java.lang.Thread.State类的注释
/**
* Thread state for a thread blocked waiting for a monitor lock.
* A thread in the blocked state is waiting for a monitor lock
* to enter a synchronized block/method or
* reenter a synchronized block/method after calling
* {@link Object#wait() Object.wait}.
/
BLOCKED,
/*
* Thread state for a waiting thread.
* A thread is in the waiting state due to calling one of the
* following methods:
*
- *
- {@link Object#wait() Object.wait} with no timeout
- {@link #join() Thread.join} with no timeout
- {@link LockSupport#park() LockSupport.park}
*
*
*
*
*
A thread in the waiting state is waiting for another thread to
* perform a particular action.
*
* For example, a thread that has called Object.wait()
* on an object is waiting for another thread to call
* Object.notify() or Object.notifyAll() on
* that object. A thread that has called Thread.join()
* is waiting for a specified thread to terminate.
*/
WAITING,