On Sun, 24 Oct 1999, Joseph Bowbeer wrote:
> Sean,
>
> The current JMM - as defined in JLS Ch. 17 - does not guarantee the
> correctness of your cache because the current JMM allows writes to be
> re-ordered. For example, the reference to the new cache entry may be written
> to main memory before the fields of the entry are written. This may lead to
> a null pointer exception in the snippet below if the reading thread sees sce
> != null but does not yet see sce.key != null. Or it may lead to an incorrect
> result if the reading thread sees sce != null and sce.key != null, but it
> does not yet see sce.value != null.
Egats, I understand the current JMM has a problem with immutable objects,
"IF" immutable objects were garunteed to be immutable, this would work. I
believe (hope) a new memory model will fix this. Otherwise I believe that
synchronization is not nescessarily nescessary for a "correct" hashtable
with limited functionality.
-------------------------------
JavaMemoryModel mailing list - http://www.cs.umd.edu/~pugh/java/memoryModel
This archive was generated by hypermail 2b29 : Thu Oct 13 2005 - 07:00:21 EDT