So my question is why the JVM does not compile the increment of an operation with int variables using the atomic Fetch-and-Increment operation supported by the CPU, which can be useful in multi-threaded programming.
Since on typical modern processors atomic read-modify-write operations (for example, increments) are tens of times more expensive than their corresponding non-atomic operations. And this will not give any advantage - the code cannot rely on atomic operations, because they are not guaranteed to be atomic. So what will be the benefit?
, , ( ):
. , . , .
( ), . โโ , , , , . ( . .)
, , , Java . , , .
, : . , ( , , , - ). , , MESI. - , .