[concurrency-interest] volatile guarantee for directbuffer

Nathan Reynolds nathan.reynolds at oracle.com
Tue Feb 14 16:58:36 EST 2012


Yes, all stores preceeding a volatile store will be visible.  It doesn't 
matter if this store is on Java heap, off Java heap or else where.  On 
x86, the JVM puts in a fence after the volatile store.  This fence 
applies to all memory accesses regardless of where they are located.

Nathan Reynolds 
<http://psr.us.oracle.com/wiki/index.php/User:Nathan_Reynolds> | 
Consulting Member of Technical Staff | 602.333.9091
Oracle PSR Engineering <http://psr.us.oracle.com/> | Server Technology

On 2/14/2012 1:25 PM, Talip Ozturk wrote:
>> I'm not sure what you mean be OffHeap, but actually that doesn't matter
>> at all: Writing to a volatile will make _all_ writes that happened
>> earlier in the same thread visible to all threads, no matter what
>> and where that earlier-written data is. (I use to tell my students
>> "writing to a volatile flushes the cache".)
> Main question wasn't about guarantees of volatiles at all. We can use
> volatile variables to guarantee 'happens-before' for the data we have
> on-heap. Does it give the same guarantees for the the data stored
> off-heap. DirectByteBuffer would be a good example of off-heap data.
>
> I at least got one answer saying 'yes' to my question.
>
> -talip
> _______________________________________________
> Concurrency-interest mailing list
> Concurrency-interest at cs.oswego.edu
> http://cs.oswego.edu/mailman/listinfo/concurrency-interest
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://cs.oswego.edu/pipermail/concurrency-interest/attachments/20120214/e731bfd5/attachment.html>


More information about the Concurrency-interest mailing list