File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
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
JavaRanch » Java Forums » Java » Threads and Synchronization
Bookmark "Object that is Locked" Watch "Object that is Locked" New topic

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{

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

Chandra Bhatt
Ranch Hand

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

I agree. Here's the link:
subject: Object that is Locked
It's not a secret anymore!