File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Threads and Synchronization and the fly likes sleep method Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Java » Threads and Synchronization
Reply Bookmark "sleep method" Watch "sleep method" New topic
Author

sleep method

memati bas
Ranch Hand

Joined: Jan 29, 2006
Posts: 85
Hi,
Can anyone explain the exact usage purpose of the sleep method in thread ?
Kj Reddy
Ranch Hand

Joined: Sep 20, 2003
Posts: 1697
Originally posted by memati bas:
Hi,
Can anyone explain the exact usage purpose of the sleep method in thread ?


Causes the current executing thread to sleep for the specified time(in milliseconds) but it do not lose ownership of any monitors.
memati bas
Ranch Hand

Joined: Jan 29, 2006
Posts: 85
What do you imply by saying " sleep " ??
Please explain...
Roy Ben Ami
Ranch Hand

Joined: Jan 13, 2002
Posts: 732
From Google:

Suspend process execution pending occurrence of an event; the term �block� is also used.


Basically, it means that the current thread does nothing for that time period (simply waits/blocks).
memati bas
Ranch Hand

Joined: Jan 29, 2006
Posts: 85
Oh thanks,
I think I kept the idea now...
amod gole
Ranch Hand

Joined: Dec 07, 2005
Posts: 81
hi memati bas,

using sleep method we are causing current to sleep for specific time
and once that thread is sleep it leaves a cpu and another thread can start their excecution

rememeber(at any instance of time cpu executes only one process)
memati bas
Ranch Hand

Joined: Jan 29, 2006
Posts: 85
Oh, thanks amod gole.
It is really explanaitory...
 
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: sleep method
 
Similar Threads
Name Joke
sleep method
WA#2 word association
wait in idle mode?
Sleep method cannot be interrupted? Is it true?