Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how java handles long and double in 32 bit architecture

how java handles the double and long in the 32 bit platform, I knew that java is platform independent, So how exactly it do that. My query is like for long does java stores the values as first 32 bit and another 32 bit in one and another memory location, how do we identify them ?

like image 639
Deepak sai Avatar asked Oct 19 '22 02:10

Deepak sai


1 Answers

Yes, Java (JVM) stores / writes the first 32 bits and then the next 32 bits one after another. That's why writing to long (or say double) fields are not thread-safe (unless they are marked as volatile)

like image 174
TheLostMind Avatar answered Oct 21 '22 17:10

TheLostMind