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 Object that is Locked Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Threads and Synchronization
Bookmark "Object that is Locked" Watch "Object that is Locked" New topic
Author

Object that is Locked

Allen Bandela
Ranch Hand

Joined: Feb 16, 2006
Posts: 128

If a thread has obtained a lock on an object, i.e. it is within a synchronized block, can another thread modify that object?

For example,
class C{
methodA(){
synchronized(this)
}
methodB(){
}
}

When Thread1 is in synchronized block in methodA, can another thread run methodB

Thanks
Chandra Bhatt
Ranch Hand

Joined: Feb 28, 2007
Posts: 1707
Yeah, other non-sync methods could be called simultaneously.


cmbhatt
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Object that is Locked