Posted By:
John_Senford
Posted On:
Monday, June 24, 2002 03:31 AM
I have a class with various sunchronized methods. A Thread enters one of the synchronized methods in which it is made to wait() for a while. Another Thread comes along and calls one of the other synchronized methods but is suspended at the very beginning of this method until the waiting Thread above finishes waiting and returns from that synchronized method. The two methods in question do NOT reference any of the SAME class/instance variables (which I originally expected to be causing the contension). Based upon the above behavour, I am left a little confused as to what is actually happening when a method is declared as being 'synchronized'. Could anybody enlighten me..
More>>
I have a class with various sunchronized methods.
A Thread enters one of the synchronized methods in which it is made to wait() for a while.
Another Thread comes along and calls one of the other synchronized methods but is suspended at the very beginning of this method until the waiting Thread above finishes waiting and returns from that synchronized method.
The two methods in question do NOT reference any of the SAME class/instance variables (which I originally expected to be causing the contension).
Based upon the above behavour, I am left a little confused as to what is actually happening when a method is declared as being 'synchronized'.
Could anybody enlighten me....?
What I hoped is that synchronizing an entire method would basically have the same effect as synchronizing each of the class/instance variables referenced from within that method.
<<Less