I am a little awkward to ask this question, but the result of the following code fragment puzzled me:
System.out.println("incrementResultResponses() has been invoked!"); final long oldValue = resultResponses; final long newValue = resultResponses++; System.out.println("Old value = " + oldValue); System.out.println("New value = " + newValue);
This outputs the following:
incrementResultResponses() has been invoked! Old value = 0 New value = 0
Why? Can concurrency affect the result here? By the way, resultResponses is long .
source share