what happens after a thread is paused with sleep java interview question and answer

646 views · Published 20 October 2012 · 2:28 · Indexed 20 October 2026

Channel: Interview DOT · 2012 · Science & Technology

Watch on YouTube

Click here - https://www.youtube.com/channel/UCd0U_xlQxdZynq09knDszXA?sub_confirmation=1 to get notifications. JOB VACANCIES IN TOP IT / NOT-IT COMPANIES

UPLOAD YOUR RESUME IN 1 MINUTE ! ! !
http://www.interviewdot.com/upload-resume/uploadresume.htm

http://www.interviewdot.com http://www.interviewdot.com http://www.interviewdot.com

Welcome to www.InterviewDot.com     How to for prepare for Interview Questions :   Interview Questions and Answers.

What happens after a thread is paused with sleep? Java Interview Question and Answers.

What happens after a thread is paused with sleep ? 

Just because a thread's sleep() expires, and it wakes up, does not mean it will return to running! Remember, when a thread wakes up, it simply goes back to the runnable state. 

The time specified in sleep() is the minimum duration in which the thread won't run, but it is not the exact duration in which the thread won't run. 

You can't, for example, rely on the sleep() method to give you a perfectly accurate timer. Although in many applications using sleep() as a timer is certainly good enough, you must know that a sleep() time is not a guarantee that the thread will start running again as soon as the time expires and the thread wakes.


Example :

Public static void main(String[] args){
 try{
 Thread.sleep(5*60*1000)  // sleep for 5 minutes.
 }catch(InterruptedException ex){
 print("exception happened");
 }
}



For more Java Interview questions and answers  - logon to www.InterviewDot.com - India's Top Interview Guide.

http://www.interviewdot.com http://www.interviewdot.com http://www.interviewdot.com

More from this channel