IntelliJ Java IDE
The moose likes Threads and Synchronization and the fly likes sleep() Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Java » Threads and Synchronization
Reply Bookmark "sleep()" Watch "sleep()" New topic
Author

sleep()

Matthew B
Greenhorn

Joined: Jul 14, 2002
Posts: 1
Will calling sleep on a thread release the threads lock an an obect/class?
Anthony Villanueva
Ranch Hand

Joined: Mar 22, 2002
Posts: 1055
No. See the sample code below:
Mr. C Lamont Gilbert
Ranch Hand

Joined: Oct 05, 2001
Posts: 1158

This comes directly from the SDK. Try to read the docs, they contain the information you seek.
sleep
public static void sleep(long millis)
throws InterruptedExceptionCauses the currently executing thread to sleep (temporarily cease execution) for the specified number of milliseconds. The thread does not lose ownership of any monitors.
Parameters:
millis - the length of time to sleep in milliseconds.
Throws:
InterruptedException - if another thread has interrupted the current thread. The interrupted status of the current thread is cleared when this exception is thrown.
See Also:
Object.notify()
 
IntelliJ Java IDE
 
subject: sleep()
 
Threads others viewed
violence or non-violence
Contacting chicken...
Name Joke
I dont know what is it
WA#2 word association
IntelliJ Java IDE