aspose file tools*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes My question about static sleep() method Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "My question about static sleep() method" Watch "My question about static sleep() method" New topic
Author

My question about static sleep() method

salih ayan
Ranch Hand

Joined: Apr 23, 2013
Posts: 59
Hi to all.
As l told you in the caption my question is about static "sleep()" method.

In K&B book where sleep() methods explains there is a sentence which confused my mind.

Before l wanna give you that example from K&B book .Look at below please....





Output is :



% java ManyNames
Run by Fred
Run by Lucy
Run by Ricky
Run by Fred
Run by Lucy
Run by Ricky
Run by Fred
Run by Lucy
Run by Ricky



And after this example book says that

You can't be certain how long a thread will actually run beforeit gets put to sleep


Yes what does K&B book want to express to reader of this book by saying upper sentece.

l already knew that when ever static sleep() methods invoked any part of the program the active thread must definetely go to sleep for some time.
But if we have accept K&B book as a reference we have to conclude that even if in the any part of code static "sleep()" method performed in that moment active thread will not has to go "sleep"

Am l right.
Please help...
Thanks for your comments..
Himai Minh
Ranch Hand

Joined: Jul 29, 2012
Posts: 734
When one thread sleeps , other threads can still run.
For example:
When thread one sleeps for 1000 ms, thread two or thread three can continue.
Or, when thread two sleeps for 1000 ms, thread one or three can continue.
Or, three threads sleeps at the same time for 1000 ms before they continue.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: My question about static sleep() method