Home > Back-end >  I will happen if the underlying concurrent problems in Java
I will happen if the underlying concurrent problems in Java

Time:05-26

Using two threads to + + operation, I see the final result
i++

CodePudding user response:

Private static int I; -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- will, because + + the same
Private int I; -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- no, because + + is an independent memory space each thread stack references
  • Related