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...


What is the life cycle of Thread ?

Answers were Sorted based on User's Feedback



What is the life cycle of Thread ?..

Answer / chinnadurai

1. when the thread create New State
2. after start() Runnable state
3. Running State
4. Wait/Block/Sleep State
5. Dead State

Is This Answer Correct ?    79 Yes 11 No

What is the life cycle of Thread ?..

Answer / harish

Once you create a Thread Class. Instantiate the Thread and
invoke the method start. It intern triggers the run method
on the Thread. Once the run method is completed, The
thread will be in dead state.

Is This Answer Correct ?    53 Yes 20 No

What is the life cycle of Thread ?..

Answer / shajin.a.xavier

Ready-to-run
A thread starts its life cycle with a call to start(). For
example

MyThread aThread = new MyThread();
aThread.start();

A call to start() will not immediately start thread's
execution but rather will move it to pool of threads
waiting for their turn to be picked for execution. The
thread scheduler picks one of the ready-to-run threads
based on thread priorities.
Running
The thread code is being actively executed by the
processor. It runs until it is swapped out, becomes
blocked, or voluntarily give up its turn with this static
method
Thread.yield();

Please note that yield() is a static method. Even if it is
called on any thread object, it causes the currently
executing thread to give up the CPU.
Waiting
A call to java.lang.Object's wait() method causes the
current thread object to wait. The thread remains
in "Waiting" state until some another thread invokes notify
() or the notifyAll() method of this object. The current
thread must own this object's monitor for calling the wait
().
Sleeping
Java thread may be forced to sleep (suspended) for some
predefined time.

Thread.sleep(milliseconds);
Thread.sleep(milliseconds, nanoseconds);

Please note that static method sleep() only guarantees that
the thread will sleep for predefined time and be running
some time after the predefined time has been elapsed.
For example, a call to sleep(60) will cause the currently
executing thread to sleep for 60 milliseconds. This thread
will be in ready-to-run state after that. It will be
in "Running" state only when the scheduler will pick it for
execution. Thus we can only say that the thread will run
some time after 60 milliseconds.
Blocked on I/O.
A java thread may enter this state while waiting for data
from the IO device. The thread will move to Ready-to-Run
after I/O condition changes (such as reading a byte of
data).
Blocked on Synchronization.
A java thread may enter this state while waiting for object
lock. The thread will move to Ready-to-Run when a lock is
acquired.
Dead
A java thread may enter this state when it is finished
working. It may also enter this state if the thread is
terminated by an unrecoverable error condition.

Is This Answer Correct ?    32 Yes 3 No

What is the life cycle of Thread ?..

Answer / 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

What is the life cycle of Thread ?..

Answer / shajin.a.xavier

Multithreading is the mechanism in which more than one
thread run independent of each other within the process.
wait (), notify () and notifyAll() methods can be used for
inter-thread communication and these methods are in Object
class. wait() : When a thread executes a call to wait()
method, it surrenders the object lock and enters into a
waiting state. notify() or notifyAll() : To remove a thread
from the waiting state, some other thread must make a call
to notify() or notifyAll() method on the same object.

Is This Answer Correct ?    16 Yes 6 No

What is the life cycle of Thread ?..

Answer / dhirendra kumar sharma

These are the life cycle of Thread.-------------
I) New thread
II) Runnable
III) Not runnable
IV) Dead

Is This Answer Correct ?    13 Yes 7 No

What is the life cycle of Thread ?..

Answer / ravikiran

start
run
destroy are the methods

born
runnable
running
sleep/blocked
dead are the states

Is This Answer Correct ?    12 Yes 7 No

What is the life cycle of Thread ?..

Answer / vaibhav mistry

The cycle of Thread is as Followed :

Start()
Run()
Wait()/Sleep()/Block()
notify()/notifyall()
Stop()

Is This Answer Correct ?    7 Yes 4 No

What is the life cycle of Thread ?..

Answer / harmeet

1.create the thread on which object u want, using Thread
interface,
2.then use obj.start() to invoke the thread
3.this method will intern call run() of Thread class
4.once it's serviced, it will come to dead state.

Is This Answer Correct ?    18 Yes 16 No

What is the life cycle of Thread ?..

Answer / karnika

The following diagram shows the states that a Java thread
can be in during its life. It also illustrates which method
calls cause a transition to another state. This figure is
not a complete finite state diagram, but rather an overview
of the more interesting and common facets of a thread's
life. The remainder of this section uses the Clock applet
previously introduced to discuss a thread's life cycle in
terms of its state.

Is This Answer Correct ?    2 Yes 0 No

Post New Answer

More Core Java Interview Questions

What is foreach loop in java?

0 Answers  


What about main() method in java ?

0 Answers  


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)

0 Answers  


How do listeners work?

0 Answers  


Need to use public,static keywords in main function?

5 Answers  


What are the 4 types of characters?

0 Answers  


Explain the difference between treeset and treemap in java?

0 Answers  


Is java platform independent?

0 Answers  


how can i connect to database in a applet ?

1 Answers  


how a programmer confirms that the data submitted has been succesfully inserted into the database(either oracle or my sql).. How a programmer confirm if there is any problem with the program he wrote for insertion

2 Answers   SAP Labs,


How can I debug the Java security exceptions and AccessControlExceptions?

0 Answers   IBM,


Why only one Class is public in one file? Explain in details. Thanks in Advance.

12 Answers  


Categories