• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
  • Tim Cooke
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Liutauras Vilda
  • Rob Spoor
  • Junilu Lacar
  • paul wheaton
Saloon Keepers:
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Carey Brown
  • Scott Selikoff
  • Piet Souris
  • Jj Roberts
  • fred rosenberger


Ranch Hand
Posts: 290
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
public class ThreadDemo extends Thread
public void run()
System.out.println("thread statred");
System.out.println("I am back from my sleep");
catch(InterruptedException e)
System.out.println("I got interrupted");
The option's are as follow's
1)Exactly 20 second's after the start method is called"I am back from my sleep" is printed"
2)we can be sure that atleast after 20 seconds elapsed, "I am back from sleep"will be printed.
3)The delay between ouytput "Thread started "and "I am back from sleep "is less or more than 20 seconds.
4)None of the above.
Th answer given is (2) and i chose 4.Please tell me the correct answer.
When a sleeping thread wake's up then it will go to the ready state.In that state it is totally up to the scheduler when it put that thread in the runnable state.Then How can a (2)option be correct?.Please tell me.
Posts: 20
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi nitin,
If u concentrate on the wording of the 2nd option which says "atleast" after 20 seconds it would print that sentence. The emphasis is on alteast that it would definitely take 20 seconds but it could take more than that also. You are absolutely right about the tansition from sleep to ready to runnable. But in any case the thread will take "ATLEAST" 20 seconds.
Hope this will help
Asif Masood
Oh sure, it's a tiny ad, but under the right circumstances, it gets bigger.
Free, earth friendly heat - from the CodeRanch trailboss
    Bookmark Topic Watch Topic
  • New Topic