Re: JavaMemoryModel: JMM and caches.

From: Doug Lea (dl@cs.oswego.edu)
Date: Mon Oct 27 2003 - 09:45:45 EST


> What I'm looking for is a mechanism that introduces a happens-before
> relationship between some defined action in a thread, and some other
> defined action that will occur at a more-or-less arbitrary future time, and
> in a different thread.

I might be misinterpreting your intent here, but I think you may be
making this out to be harder than it is. If you need
ordering/visibility without locking, make sure that reader threads read
a volatile field that is written by writer threads. Some variant of
this is used (sometimes in conjunction with locking or atomic updates
to coordinate writers) in most "concurrently readable data structures",
for example in JSR-166 ConcurrentHashMap and ConcurrentLinkedQueue.
(See http://gee.cs.oswego.edu/dl/concurrency-interest/index.html)

-Doug

-------------------------------
JavaMemoryModel mailing list - http://www.cs.umd.edu/~pugh/java/memoryModel



This archive was generated by hypermail 2b29 : Thu Oct 13 2005 - 07:00:52 EDT