[concurrency-interest] Happens Before guarantee in case of unsafe.putOrderedObject and corresponding nomal read of a variable

vikas vikas.vksingh at gmail.com
Fri Sep 5 00:15:11 EDT 2014


Just some minor modifications for in the above mail

So Suppose initially
 * ds.get(2) == null  and ds.get(3) refers to a integer Object 7 i.e new
Integer(7) : *
then if 
  
  T1 Thread : 
       Integer v1 = ds.get(3); // suppose v1 is not null it contains 7 as an
int value
       v1.setValue(5);
       ds.set(2, v1);
    
  T2 thread :
       Integer v1 = ds.get(2);
       if(v1 != null ) { // *normal read i.e is not a volatile read*
           sysout(v1.get()) ;  //* Is thread 2 always guaranteed to  see 5 *
       }
  
*It would be very helpful if somebody can tell me if thread  T2 is always
guaranteed to see 5 or not*





--
View this message in context: http://jsr166-concurrency.10961.n7.nabble.com/Happens-Before-guarantee-in-case-of-unsafe-putOrderedObject-and-corresponding-nomal-read-of-a-variabe-tp11255p11256.html
Sent from the JSR166 Concurrency mailing list archive at Nabble.com.


More information about the Concurrency-interest mailing list