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?

Answers were Sorted based on User's Feedback



explain the life cycle of thread?..

Answer / ganesh

There are number of stages for executing the Thread.
1.ready to run
2.run
3.suspend(wait,sleep)
4.resume(notify,notify all)
5.kill.

Is This Answer Correct ?    64 Yes 26 No

explain the life cycle of thread?..

Answer / vazza jones

The thread states are:

- New (created but start mtd not called)
- Runnable (Ready to run, waiting for CPU cycles)
- Running (allocated CPU cycle)
- Suspended (timed sleeping)
- Wait (waiting for a notify)
- Stopped (Completed)

Is This Answer Correct ?    40 Yes 4 No

explain the life cycle of thread?..

Answer / god&

There are five states New,Runnable,Running,Blocked,Dead

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.

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

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.

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.

Blocked - A thread can enter in this state because of
waiting the resources that are hold by another thread.

Is This Answer Correct ?    34 Yes 3 No

explain the life cycle of thread?..

Answer / srinivas

There are number of stages for executing the Thread.
1.born state
2.runnable
3.running(wait,sleep)
4.blocked(wait,sleep)
5.destroy.

Is This Answer Correct ?    45 Yes 22 No

explain the life cycle of thread?..

Answer / rakesh

1) new bron state
2) runnable state
3) running state
4) blocked state
5) dead state

Is This Answer Correct ?    26 Yes 3 No

explain the life cycle of thread?..

Answer / srinivas ponugoti

There are number of stages for executing the Thread.
1.born state
2.runnable
3.running
4.blocked(wait,sleep,suspend)
5.destroy(stop).

Is This Answer Correct ?    27 Yes 13 No

explain the life cycle of thread?..

Answer / nishant s mevawala

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 ?    7 Yes 4 No

explain the life cycle of thread?..

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

explain the life cycle of thread?..

Answer / manoj kumar

Thread : A Thread is a saparate path between ur source code
to execution .
it have
new , ready ,running , dispatch , stop

Is This Answer Correct ?    8 Yes 6 No

explain the life cycle of thread?..

Answer / jetender

b/c in every program at least one thread automically involve

Is This Answer Correct ?    15 Yes 17 No

Post New Answer

More Core Java Interview Questions

wHAT IS DEFAULT SPECIFIER IN JAVA wHAT IS DEFAULT CONSTRUCTOR IN JAVA wHAT IS DEFAULT METHOD IN JAVA

12 Answers   IBM,


What about features of local inner class?

0 Answers  


why should we get the following error ? Exception in main method NoClassDefFoundError:classname could anyone give the detail clarification on how java compiler can look for .class file?

2 Answers  


What one should take care of, while serializing the object?

0 Answers  


Can you explain inner class.

0 Answers  


In method overloading ,if i change the return type to Long instead of INT,is the program execute

6 Answers   HCL,


Is final static java?

0 Answers  


What is constructor in java ?

0 Answers  


what modifiers are used with top-level class?

2 Answers  


What is a predicate method?

0 Answers  


Why we need to serialize the object

11 Answers   CTS, Geometric Software,


What do you mean by light weight and heavy weight components?

0 Answers  


Categories