aspose file tools
The moose likes Threads and Synchronization and the fly likes Object that is Locked Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


JavaRanch » Java Forums » Java » Threads and Synchronization
Reply 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: 127

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


Life is like a day. If the day is of no use, neither a month or a year.
Chandra Bhatt
Ranch Hand

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


cmbhatt
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Object that is Locked
 
Similar Threads
synchronized block
Doubt in Threads
thread lock (monitor) question
Multiple static synchronized methods in one class
Synchronization on Threads in Java