This week's book giveaway is in the OO, Patterns, UML and Refactoring forum.
We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line!
See this thread for details.
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes About Object lock 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 "About Object lock" Watch "About Object lock" New topic

About Object lock

Niu Xiuyuan
Ranch Hand

Joined: Jun 08, 2001
Posts: 68
when wait() or sleep() function is invoked,if they hold the object lock?
synchronized( lock )

Sun Certified Java Programmer<br />Sun Certified Web Component Developer
David Weitzman
Ranch Hand

Joined: Jul 27, 2001
Posts: 1365
wait() does not hold the lock, sleep() does
Jose Botella
Ranch Hand

Joined: Jul 03, 2001
Posts: 2120
Be careful Niu you will get an IllegalMonitorStateException if you run the code because wait has not been called over lock.
Make sure the following
This way you wont't get the mentioned exception
[This message has been edited by Jose Botella (edited January 01, 2002).]

SCJP2. Please Indent your code using UBB Code
Have you checked out Aspose?
subject: About Object lock
It's not a secret anymore!