ALLInterview.com :: 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                      
tip   To Refer this Site to Your Friends   Click Here
Google
   
 
Categories  >>  Software  >>  Java Related  >>  Java J2EE  >>  Core Java
 
 


 

 
 Core Java interview questions  Core Java Interview Questions
 Advanced Java interview questions  Advanced Java Interview Questions
 Swing interview questions  Swing Interview Questions
 EJB interview questions  EJB Interview Questions
 Servlets interview questions  Servlets Interview Questions
 Struts interview questions  Struts Interview Questions
 JDBC interview questions  JDBC Interview Questions
 JMS interview questions  JMS Interview Questions
 SunOne interview questions  SunOne Interview Questions
 J2EE interview questions  J2EE Interview Questions
 Weblogic interview questions  Weblogic Interview Questions
 Websphere interview questions  Websphere Interview Questions
 Java Networking interview questions  Java Networking Interview Questions
 Java J2EE AllOther interview questions  Java J2EE AllOther Interview Questions
Question
explain the life cycle of thread?
 Question Submitted By :: Venu
I also faced this Question!!     Rank Answer Posted By  
 
  Re: explain the life cycle of thread?
Answer
# 1
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 ?    57 Yes 26 No
Ganesh
 
  Re: explain the life cycle of thread?
Answer
# 2
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 ?    40 Yes 20 No
Srinivas
 
 
 
  Re: explain the life cycle of thread?
Answer
# 3
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 12 No
Srinivas Ponugoti
 
  Re: explain the life cycle of thread?
Answer
# 4
b/c in every program at least one thread automically involve 
Is This Answer Correct ?    11 Yes 17 No
Jetender
 
  Re: explain the life cycle of thread?
Answer
# 5
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 ?    36 Yes 4 No
Vazza Jones
 
  Re: explain the life cycle of thread?
Answer
# 6
1) new bron state
2) runnable state
3) running state
4) blocked state
5) dead state
 
Is This Answer Correct ?    21 Yes 2 No
Rakesh
 
  Re: explain the life cycle of thread?
Answer
# 7
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 4 No
Manoj Kumar
 
  Re: explain the life cycle of thread?
Answer
# 8
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 ?    29 Yes 2 No
God&039;y
 
  Re: explain the life cycle of thread?
Answer
# 9
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 3 No
Nishant S Mevawala
 

 
 
 
Other Core Java Interview Questions
 
  Question Asked @ Answers
 
Diff between C++ and java? TCS9
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 SAP-Labs2
how cani read a command line argument?(usingfile object).  3
why marker interfaces are there in java Digital-Group4
Howmany address lines are required to addressing 1 MB memory? Hexaware6
The following program is Overloading or Overriding? public class PolymorphismEx { public int sampleMethod(int a) { return a; } public String sampleMethod(int a) { return "Is it Overloading or Overriding???"; } } Ness-Technologies2
I need some details about an employee. i have only the employee id in my presentation layer(JSP).I entered that ID and click "Show Details" Button. Question is how the JSP pass that id to Controller layer and DAO and what mechanism we are using to retrive data from DB and how the data passed to JSP as a Output. Please explain in detail. TCS1
Why non nested classes in java are not having marked as protected access specifier Google2
wHAT IS DEFAULT SPECIFIER IN JAVA wHAT IS DEFAULT CONSTRUCTOR IN JAVA wHAT IS DEFAULT METHOD IN JAVA IBM12
What are different types of Exceptions?.  8
Explain pass by reference and pass by value? Wipro7
Which of the following can be referenced by a variable? A. The instance variables of a class only B. The methods of a class only C. The instance variables and methods of a class  2
 
For more Core Java Interview Questions Click Here 
 
 
 
 
 


   
Copyright Policy  |  Terms of Service  |  Help  |  Site Map 1  |  Articles  |  Site Map  |   Site Map  |  Contact Us interview questions urls   External Links 
   
Copyright © 2012  ALLInterview.com.  All Rights Reserved.

ALLInterview.com   ::  Forum9.com   ::  KalAajKal.com