:: Home Page            
 Advertise your Business Here     
Browse  |   Placement Papers  |   Company  |   Code Snippets  |   Certifications  |   Visa Questions
Post Question  |   Post Answer  |   My Panel  |   Search  |   Articles  |   Topics  |   ERRORS new
   Refer this Site  Refer This Site to Your Friends  Site Map  Bookmark this Site  Set it as your HomePage  Contact Us     Login  |  Sign Up                      
Categories >> Software >> Java Related >> Java J2EE >> Core Java


 Core Java interview questions  Core Java Interview Questions (1728)
 Advanced Java interview questions  Advanced Java Interview Questions (332)
 Swing interview questions  Swing Interview Questions (44)
 EJB interview questions  EJB Interview Questions (134)
 Servlets interview questions  Servlets Interview Questions (255)
 Struts interview questions  Struts Interview Questions (196)
 JDBC interview questions  JDBC Interview Questions (187)
 JMS interview questions  JMS Interview Questions (9)
 SunOne interview questions  SunOne Interview Questions (3)
 J2EE interview questions  J2EE Interview Questions (71)
 Weblogic interview questions  Weblogic Interview Questions (147)
 Websphere interview questions  Websphere Interview Questions (14)
 Java Networking interview questions  Java Networking Interview Questions (20)
 Java J2EE AllOther interview questions  Java J2EE AllOther Interview Questions (87)
explain the life cycle of thread?
 Question Submitted By :: Core-Java
I also faced this Question!!     Answer Posted By  
# 1
There are number of stages for executing the Thread.
1.ready to run
4.resume(notify,notify all)
Is This Answer Correct ?    62 Yes 26 No
# 2
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 ?    38 Yes 4 No
Vazza Jones
# 3
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

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 ?    30 Yes 2 No
# 4
There are number of stages for executing the Thread.
1.born state
Is This Answer Correct ?    45 Yes 21 No
# 5
1) new bron state
2) runnable state
3) running state
4) blocked state
5) dead state
Is This Answer Correct ?    25 Yes 2 No
# 6
There are number of stages for executing the Thread.
1.born state
Is This Answer Correct ?    27 Yes 12 No
Srinivas Ponugoti
# 7
Ready-to-run: A thread starts its life cycle with a call to start().
For example
MyThread aThread = new MyThread();
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
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, 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 3 No
Nishant S Mevawala
# 8
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 5 No
Manoj Kumar
# 9
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 ?    1 Yes 0 No
Dinesh Kumar
# 10
b/c in every program at least one thread automically involve 
Is This Answer Correct ?    12 Yes 17 No

Other Core Java Interview Questions
  Question Asked @ Answers
Given: 10. interface A { void x(); } 11. class B implements A { public void x() { } public voidy() { } } 12. class C extends B { public void x() {} } And: 20. java.util.List list = new java.util.ArrayList(); 21. list.add(new B()); 22. list.add(new C()); 23. for (A a:list) { 24. a.x(); 25. a.y();; 26. } What is the result? 1 Compilation fails because of an error in line 25. 2 The code runs with no output. 3 An exception is thrown at runtime. 4 Compilation fails because of an error in line 20.   3
Can we override the main method?   3
why pointer is not used in java?   3
When we give defination of interface method in the class why method must be public???   2
what is the meaning of java.lang and java.util   6
why is multiple inheritance not allowed in java? Elementus-Technologies 7
what is platform dependent translation and platform dependent programming language   2
public class Test { public static void main(String ar[]) { Integer a = 10; Integer b =10; Integer c = 145; Integer d = 145; System.out.println(a==b); System.out.println(c==d); } } Igate 7
What modifiers are used for interface declaration?   7
In Inheritance if we are implementing Multi level inheritance and all class having same name of variable and now i want to access each class variable and how it is possible?   2
what is the main class of all the classes Photon 5
For more Core Java Interview Questions Click Here 

Copyright Policy  |  Terms of Service  |  Articles  |  Site Map  |  RSS Site Map  |  Contact Us
Copyright 2013  All Rights Reserved.   ::