Hi, Lets say a class has two synchronized methods A() and B() and there are two threads TA and TB. Is it possible for TA to execute A() and TB to execute method B()independently at the same time? In other words, when a thread acquires the monitor of an object to execute a synchronized method, does it have the monitor for the specific method of the object or for the whole of the object? Thanks.
srini v
Greenhorn
Joined: Dec 15, 2003
Posts: 11
posted
0
Hi:
does it have the monitor for the specific method of the object or for the whole of the object?
The lock is for the whole of the object. Also note that java threads are reentrant. cheers