thread stopping & blocking in java

Stopping a thread:

Whenever we want to stop a thread from running further,we may do so by calling its stop() method, like:
aThread.stop();

This statement cause the thread to move to the dead state.The stop method may used when the premature death of a thread is desired.

Blocking a thread:
A thread can also be temporarily suspended or blocked from entering into the runnable and subsequently running state by using either of the following thread methods:
sleep()
//blocked for a specified time

suspend()
//blocked until further orders

wait()
//blocked until certain condition occurs
These methods cause the thread to go into the blocked(or not-runnable) state.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s