Java Tutorial: Suspend and Resume threads


This tutorial will help you to understand how to suspend and resume threads in java.

run following java programs in your IDEs. I suggest using Eclipse.

Suspend1

In this program we are suspending thread just once.

but if you want to suspend thread each time you increment ‘i’ then,

Suspend2

i have commented previous mysuspend(),myresume() function and just call them in your for loop.

Advertisements

One comment

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