...
>Example:
>class SinCacheEntry {
> final Float key;
> final Float value;
>}
>class SinAlgo {
> final SinCacheEntry cache[] = new SinCacheEntry[CACHE_SIZE];
> public Float doit(Float key) {
> Float answer;
> {
> // our single allowed load.
> SinCacheEntry sce = this.cache[key.hashCode() % this.cache.length];
> if (sce != null) {
> if (sce.key.equals(key)) return sce.value;
> }
> }
...
>Assuming that sin_impl is thread safe, I'm willing to say that the method
>doit should also be thread safe (at least under some reasonably safe
>model). This is without any synchronization at all.
>Are my assumptions reasonable? I'm working with cases that must remain
>atomic with no synchronization.
>- Sean
As far as I understand, a weak synchronization model would
not guarantee that a thread that sees the updated value
of sce.key will necessarily see the updated value of
sce.value; it may see the default value. Please correct me if I'm wrong.
-- Rob Strom------------------------------- 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