标签:分享 同步代码块 tor nano ESS 图片 other 启动 对象
java.lang.Thread.State
成员内部类
NEW:还未启动
Thread state for a thread which has not yet started.
RUNNABLE:正在jvm中运行,但是可能正在等待操作系统的其他资源
Thread state for a runnable thread.
A thread in the runnable state is executing in the Java virtual machine but it may be waiting for other resources from the operating system such as processor.
BLOCKED:受阻塞,并且正在等待监视器锁
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}.
WAITING:处于等待状态的线程,正在等待另一个线程执行特定的操作
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.
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.
TIMED_WAITING
Thread state for a waiting thread with a specified waiting time.
A thread is in the timed waiting state due to calling one of the following methods with a specified positive waiting time:
{@link #sleep Thread.sleep}
{@link Object#wait(long) Object.wait} with timeout
{@link #join(long) Thread.join} with timeout
{@link LockSupport#parkNanos LockSupport.parkNanos}
{@link LockSupport#parkUntil LockSupport.parkUntil}
TERMINATED
Thread state for a terminated thread.
The thread has completed execution.
Thread start()
sleep() sleep(?)
join()
Object wait() notify() notifyAll()
wait(?)
新建(new)
可运行(Runnable)
阻塞(block)
死亡(dead)
新创建一个线程,线程处于新建状态(new)
调用线程的start()方法,线程进入可运行状态(Runnable),该线程位于可运行线程池中,等待被线程调度选中,获取CPU使用权,此时线程处于就绪状态
处于就绪状态的线程一点获得CPU使用权,进入运行状态
一个线程在执行过程中,想获得某一资源的锁,但是该资源又被其它线程占用,此时,当前线程处于阻塞状态(例如,进入一个同步方法或者同步代码块,要先获得锁)
一个线程处于等待(waiting)状态,表示该线程正在等待其它线程执行特定的操作
例如,一个线程调用了Object类的空参的wait方法,表示该线程等待其它线程调用该对象的notify或者notifyAll方法
一个线程调用了Thread类的空参的join方法,表示该线程在等待一个特定的线程终止
一个线程处于超时等待状态(timed_waiting),和waiting不同的是,将在特定的时间内自行返回
一个线程执行完毕,进入终止状态(terminated)
标签:分享 同步代码块 tor nano ESS 图片 other 启动 对象
原文地址:https://www.cnblogs.com/duanjiapingjy/p/9426825.html