2.multi-thread: life cycle

[img]http://www.roseindia.net/java/thread/life-c1.gif[/img]

1. [b]New state[/b] After the creations of Thread instance the thread is in this state but before the start() method invocation. At this point, the thread is considered not alive.

2. [b]Runnable (Ready-to-run) state [/b]. A thread start its life from Runnable state. A thread first enters runnable state after the invoking of start() method but a thread can return to this state after either running, waiting, sleeping or coming back from blocked state also. [u]On this state a thread is waiting for a turn on the processor[/u].

3. [b]Running state[/b] . A thread is in running state that means the thread is currently executing.[u] there is only one way to enter in Running state: the scheduler select a thread from runnable pool[/u].

4. [b]Dead state [/b]. A thread can be considered dead when its run() method completes. If any thread comes on this state that means it cannot ever run again.

5. [b]Blocked[/b] - A thread can enter in this state because of waiting the resources that are hold by another thread.

[img]http://www.roseindia.net/java/thread/multi-thread/JavaMu3.gif[/img]

[b]Sleeping[/b] On this state, the thread is still alive but it is not runnable. On this state a thread sleeps for a specified amount of time. You can use the method sleep( ) to stop the running state of a thread.

[b]Waiting for Notification[/b] A thread waits for notification from another thread. [u]The thread sends back to runnable state after sending notification from another thread[/u].


[b]Blocked on I/O[/b] The thread waits for completion of blocking operation. A thread can enter on this state because of waiting I/O resource. In that case the thread sends back to runnable state after availability of resources.

[b]Blocked for joint completion[/b] The thread can come on this state because of waiting the completion of another thread.

[b]Blocked for lock acquisition[/b] The thread can come on this state because of waiting to acquire the lock of an object.
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值