Originally posted by Ajith Kallambella:
Static synchronized block would lock the entire Class.
i check the khalid's book, and the following is my understanding:
as i said before, i think the monitor of static synchronied method is different from the monitor of general sychronized method. the former is " a class-sepcific monitor" (quoted from the book); the later is just the object monitor. Plz attention one is
CLASS monitor, anther is
OBJECT one.
a
thread acquires the class monitor before it can process with the excution of any static sychronized method in the class, blocking other threads wishing to excute any <red>
such methods</red> in the same <red>class</red>.
moreover, the thread with static sychronized method doesnot effect the performance of the other threads acquiring the monitor on any object of the class to excute the only <red>sychronized</red> non-static methods.
the class monitor and object monitor are , after all, independent
each other.
that is clear? if not, plz refer to khalid's book. teh explaination is cool and like oracle(not database,just english
word)!
regds
George