aspose file tools*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Thread 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 "Thread" Watch "Thread" New topic
Author

Thread

Fisher Daniel
Ranch Hand

Joined: Sep 14, 2001
Posts: 582
Hi all,
Can method sleep() stop the executing of thread?
thanks
daniel
Ragu Sivaraman
Ranch Hand

Joined: Jul 20, 2001
Posts: 464
From JDK docs:
sleep:
Causes the currently executing thread to sleep (cease execution) for the specified number of milliseconds plus the specified number of nanoseconds. The thread does not lose ownership of any monitors.
stop:
Stopping a thread with Thread.stop causes it to unlock all of the monitors that it has locked (as a natural consequence of the unchecked ThreadDeath exception propagating up the stack).
So i dont think sleep stops the thread...since the thread gets to retain its lock even when its sleeping
let me know
Nain Hwu
Ranch Hand

Joined: Sep 16, 2001
Posts: 139
Even though stop() can stop a thread, but its usage is
strongly disapproved (JDK API says it is deprecated).
Please take a look at JDK API.
Marilyn de Queiroz
Sheriff

Joined: Jul 22, 2000
Posts: 9046
    
  10
From JDK docs:
sleep:
Causes the currently executing thread to sleep (cease execution) for the specified number of milliseconds plus the specified number of nanoseconds.

"cease execution" == "stop execution" ( although it is just a temporary cesation and not a permenant one ). Depends on how you interpret the word "stop" in the question.


JavaBeginnersFaq
"Yesterday is history, tomorrow is a mystery, and today is a gift; that's why they call it the present." Eleanor Roosevelt
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Thread