一张图片,让你彻底清除线程的生命周期
下面是状态机的相应的描述:
0至4分别:CREATED, TERMINATED,RUNNABLE, RUNNING 和 NON_RUNNABLE
THREAD = CREATED, CREATED = (start ->RUNNABLE |stop ->TERMINATED), RUNNING = ({suspend,sleep}->NON_RUNNABLE |yield ->RUNNABLE |{stop, end} ->TERMINATED | run ->RUNNING), RUNNABLE = (suspend ->NON_RUNNABLE | dispatch ->RUNNING |stop ->TERMINATED), NON_RUNNABLE = (resume ->RUNNABLE |stop ->TERMINATED), TERMINATED = STOP.
说明:本内容摘自 <<Concurrency: State Models & Java Programs (2nd Edition)>>
版权声明:本文博主原创文章,博客,未经同意不得转载。