Volatile or synchronized for primitive type?
        Posted  
        
            by DKSRathore
        on Stack Overflow
        
        See other posts from Stack Overflow
        
            or by DKSRathore
        
        
        
        Published on 2009-11-22T17:02:15Z
        Indexed on 
            2010/03/14
            5:25 UTC
        
        
        Read the original article
        Hit count: 433
        
In java, assignment is atomic if the size of the variable is less that or equal to 32 bits but is not if more than 32 bits. What(volatile/synchronized) would be more efficient to use in case of double or long assignment.
like,
  volatile double x = y;
synchronized is not applicable with primitive argument. How do i use synchronized in this case. Of course I don't want to lock my class. so this should not be used. 
© Stack Overflow or respective owner