Originally posted by clyde melly:
so the conept of static comes into picture.if the synchronized method is static,then t2 has to wait to get the lock.If non static no problems.am i right or i have misunderstood???
how on earth is the object member still modifiable when the other thread has still got a hold of it?
- Chapter 17
To synchronize threads, the Java programming language uses monitors, which are a high-level mechanism for allowing only one thread at a time to execute a region of code protected by the monitor. The behavior of monitors is explained in terms of locks; there is a lock associated with each object.
- Chapter 14
Acquiring the lock associated with an object does not of itself prevent other threads from accessing fields of the object or invoking unsynchronized methods on the object. Other threads can also use synchronized methods or the synchronized statement in a conventional manner to achieve mutual exclusion.