[concurrency-interest] volatile guarantee for directbuffer

Pavel Rappo pavel.rappo at gmail.com
Tue Feb 14 09:28:41 EST 2012


Sorry for previous email.

> Can I assume that thread2 did read the byte[] and long values?

Yes.

> Does volatile-reads give us happens-before guarantee for OffHeap data?

Could you please give an example of such a data?

On 14 Feb 2012, at 18:27, Pavel Rappo wrote:

> 
> On 14 Feb 2012, at 18:09, Talip Ozturk wrote:
> 
>> Say we have thread1 and thread2. Both can access a volatile boolean
>> variable, 'volatileVar' and DirectByteBuffer instance 'directBuffer'
>> 
>> thread1:
>> directBuffer.put(myByteArray);
>> directBuffer.putLong(myLong);
>> volatileVar = true;
>> 
>> thread2:
>> if (volatileVar) {
>> // read the directBuffer
>> directBuffer.get(myByteArray);
>> long myLong = directBuffer.getLong();
>> }
>> 
>> Can I assume that thread2 did read the byte[] and long values?
>> 
>> Does volatile-reads give us happens-before guarantee for OffHeap data?
>> 
>> Thanks,
>> -talip
>> _______________________________________________
>> Concurrency-interest mailing list
>> Concurrency-interest at cs.oswego.edu
>> http://cs.oswego.edu/mailman/listinfo/concurrency-interest
> 



More information about the Concurrency-interest mailing list