aspose file tools
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

Win a copy of Groovy Fundamentals video training course this week in the Groovy forum!
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
It is sorta covered in the JavaRanch Style Guide.
subject: About Object lock