Eric Blake wrote:

>No - even accessing a simple field must be synchronized, for this
>reason:
>
>Suppose thread A is in the middle of calling clear() when thread B calls
>size().  Notice in clear() that the size is not changed until after all
>entries have been set to null, meaning that B will read a larger size
>than what is actually there.
>

So? Even if size() is synchronized there is nothing to stop another 
thread calling clear() after size()'s lock is released but before the 
first thread does anything with the value returned by size().

The only way to avoid issues like this is for the caller to put a big 
synchronized block around all its calls into the hashtable.

regards

Bryce.




_______________________________________________
Classpath mailing list
[EMAIL PROTECTED]
http://mail.gnu.org/mailman/listinfo/classpath

Reply via email to