What is the life cycle of Thread ?

Answer Posted / sasikala d

1. New state - 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. Runnable (Ready-to-run) state - 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. On this
state a thread is waiting for a turn on processor.
3. Running state - A thread is in running state that
means the thread is currently executing. There are several
ways to enter in Runnable state but there is only one way
to enter in Running state: the scheduler select a thread
from runnable pool.
4. Dead state - 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. Blocked - A thread can enter in this state because
of waiting the resources that are hold by another thread.

Is This Answer Correct ?    16 Yes 2 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is the difference between a scrollbar and a scrollpane?

550


Explain the meaning of java applet.

595


What is a classloader in java?

531


how many types of Inheritance?

641


What is a variable analysis?

628






Define "Access specifiers" in java.

606


What are the main uses of the super keyword?

547


how does the run() method in runnable work? : Java thread

511


Name some classes present in java.util.regex package.

599


What do you understand by overloading and overriding in java?

535


how come we know the object is no more used in the class?

5393


Can a abstract class be declared final?

560


What is java in detail?

553


how do I create a runnable with inheritance? : Java thread

504


Say you want to store the information about a number of pets in an array. Typical information that you could store for each pet (where relevant) would be • Breed of animal • Animal's name • Its birth date • Its sex • Whether it has been sterilised or not • When it is due for its next inoculation • When it last had its wings clipped For each type of pet (eg. dog, cat or bird) you would typically define a class to hold the relevant data. Note: You do not need to implement these classes. Just answer the following questions. 3.1.1 What would be the advantage of creating a superclass (eg. Pet) and declaring an array of Pet objects over simply using an array of Objects, storing each of the instances of the different pet classes (eg. Dog, Cat or Bird) in it? 3.1.2 Would you define Pet as a class or as an interface? Why? (2) (2)

1341