my dog learned polymorphism*
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: 1707
Yeah, other non-sync methods could be called simultaneously.

With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
subject: Object that is Locked
Similar Threads
Multiple static synchronized methods in one class
Synchronization on Threads in Java
Doubt in Threads
thread lock (monitor) question
synchronized block