ThreadState

来源:互联网 发布:手把手教你单片机 pdf 编辑:程序博客网 时间:2024/03/28 17:43

当一个ThreadState刚刚被创建的时候,它的Threadstate是unstarted。

调用Start()之后,它的Threadstate变成Running

如果想让它阻塞,调用sleep()方法,threadstate变成waitesleepjoin

此外这个线程如果调用了其他对象的wait或者join也会使自身的threadstate变成waitsleepjoin

处于waitesleepjoin的状态如果想唤醒它,可使用interrupt方法,将在线程中引发threadinterruptedexception异常,进入中断处理模式,threadstate变成running

另外一个线程调用此线程的abort,那么此线程的threadstate变成AbortRequested

线程响应 Abort 请求。threadstate变成stop

线程停止threadstate为stop



0 0
原创粉丝点击