Yes, a statement such as
foo++;
foo++;
To copy to clipboard, switch view to plain text mode
can in the object code expand to several instructions. Pseudocode:
register = foo;
register += 1;
foo = register;
register = foo;
register += 1;
foo = register;
To copy to clipboard, switch view to plain text mode
If another thread is also executing the same instructions, it may have been interrupted right after the first pseudo-instruction above. The variable will then be incremented only once even when two threads tried to increment it...
Bookmarks