Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

explain the life cycle of thread?

Answer Posted / dinesh kumar

1 Newborn State

2 Runnable State

3 Running State

4 Blocked State

5 Dead State
1 Newborn State

When we create a thread it will be in Newborn State.

The thread is just created still its not running.

We can move it to running mode by invoking the start() method and it can be killed by using stop() method.
2 Runnable State

It means that thread is now ready for running and its waiting to give control.

We can move control to another thread by yield() method.

3 Running State

It means thread is in its execution mode becaause the control of cpu is given to that particular thread.

It can be move in three different situation from running mode.
These all are different methods which can be apply on running thread and how the state is changing and how we can come in our original previous state using different methods are shown in above figure.

4 Blocked State

A thread is called in Blocked State when it is not allowed to entering in Runnable State or Running State.

It happens when thread is in waiting mode, suspended or in sleeping mode.

5 Dead State

When a thread is completed executing its run() method the life cycle of that particular thread is end.

We can kill thread by invoking stop() method for that particular thread and send it to be in Dead State.

Is This Answer Correct ?    3 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is a finally block?

978


Why there is no call by reference in java?

918


Explain illegalmonitorstateexception and when it will be thrown?

1096


What is the meaning of flag day?

1019


How to add menushortcut to menu item?

996


How long will it take to learn java?

989


What is the use of 'super' keyword inside a constructor?

964


Can you access non static variable in static context?

1038


Is java 11 paid version?

981


what is deadlock? : Java thread

1005


What is the default size of arraylist in java?

1120


Which of the following classes will have more memory allocated?

1015


What is the difference between procedural and object-oriented programs?

968


What's the difference between comparison done by equals method and == operator?

967


How will you get the platform dependent values like line separator, path separator, etc., ?

1021