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
What is the difference between a scrollbar and a scrollpane?
Explain the meaning of java applet.
What is a classloader in java?
how many types of Inheritance?
What is a variable analysis?
Define "Access specifiers" in java.
What are the main uses of the super keyword?
how does the run() method in runnable work? : Java thread
Name some classes present in java.util.regex package.
What do you understand by overloading and overriding in java?
how come we know the object is no more used in the class?
Can a abstract class be declared final?
What is java in detail?
how do I create a runnable with inheritance? : Java thread
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)