Java - Interview Questions and Answers for 'Thread states' | Search Java Interview Question - javasearch.buggybread.com
Javasearch.buggybread.com
Share

Search Java Interview Questions


 2137 questions in repository.
 There are more than 200 unanswered questions.
Click here and help us by providing the answer.
Label / Company      Label / Company / Text

   



Interview Questions and Answers for 'Thread states' - 7 question(s) found - Order By Newest

Frequently asked to fresh graduates.
 Q1. Explain Thread States ?Operating System
Admin
info@buggybread.com
Ans. Runnable - waiting for its turn to be picked for execution by the thread schedular based on thread priorities.

Running - The processor is actively executing the thread code. It runs until it becomes blocked, or voluntarily gives up its turn.

Waiting: A thread is in a blocked state while it waits for some external processing such as file I/O to finish.

Sleeping - Java threads are forcibly put to sleep (suspended) with Thread.sleep. they can resume using Thread.resume method.

Blocked on I/O - Will move to runnable after I/O condition like reading bytes of data etc changes.

Blocked on synchronization - Will move to Runnable when a lock is acquired.

Dead - The thread is finished working.

 Help us improve. Please let us know the company, where you were asked this question :   

   Like      Discuss      Correct / Improve     java   threads   multi threading   scheduling   thread states   basic interview question     Cognizant (CTS)      basic        frequent

Try 2 Question(s) Test


Usually asked only to fresh graduates.
 Q2. What is the initial state of a thread when it is created and started?
Anonymous
Ans. Ready state.

 Help us improve. Please let us know the company, where you were asked this question :   

   Like      Discuss      Correct / Improve     operating system   threads   multi threading   java   thread states     Cognizant (CTS)      basic        frequent


 Q3. What state does a thread enter when it terminates its processing?
Anonymous
Ans. When a thread terminates its processing, it enters the dead state.

 Help us improve. Please let us know the company, where you were asked this question :   

   Like      Discuss      Correct / Improve     java   threads   multi threading   scheduling   thread states


 Q4. Difference between yield() and sleeping()?
Admin
info@buggybread.com
Ans. When a task invokes yield(), it changes from running state to runnable state. When a task invokes sleep(), it changes from running state to waiting/sleeping state.

 Help us improve. Please let us know the company, where you were asked this question :   

   Like      Discuss      Correct / Improve     java   threads   multi threading   scheduling   thread states   yield   sleeping


 Q5. What is the initial state of a thread when it is created and started ?

a. Wait
b. Running
c. Ready
d. Sleep
Anonymous
Ans. Ready

 Help us improve. Please let us know the company, where you were asked this question :   

   Like      Discuss      Correct / Improve     java   threads   multithreading   thread states


 Q6. What state does a thread enter when it terminates its processing?

a. Wait
b. Ready
c. Dead
d. Running
Anonymous
Ans. Dead

 Help us improve. Please let us know the company, where you were asked this question :   

   Like      Discuss      Correct / Improve     java   threads   multithreading   thread states


 Q7. Difference between Yielding and Sleeping ?

Ans. When a task invokes its yield method, it returns to the ready state. When a task invokes its sleep method, it returns to the waiting state.

 Help us improve. Please let us know the company, where you were asked this question :   

   Like      Discuss      Correct / Improve     multithreading  threads  yielding  sleeping  thread states




Subscribe to Java News and Posts. Get latest updates and posts on Java from Buggybread.com
Enter your email address:
Delivered by FeedBurner



comments powered by Disqus
 

Help us and Others Improve. Please let us know the questions asked in any of your previous interview.

Any input from you will be highly appreciated and It will unlock the application for 10 more requests.

Company Name:
Questions Asked:
         

X Close this

X Close this

Help Us Improve.
Please share your
interview experience.

Company Name:   


Questions Asked: