[concurrency-interest] How bad can volatile long++ be?

Sam Berlin sberlin at gmail.com
Mon Dec 10 10:53:47 EST 2007


Hi Folks,

I'm fairly certain that ++ is not an atomic operation, even on
volatile variables, on longs (and quite possibly ints).  Given that is
true (which it very well might not be), is it suspectible to problems
where a wildly wrong number can be produced (due to different bytes
being updated at different times from different threads), or will it
just cause some increments to effectively not happen?

Thanks!
 Sam


More information about the Concurrency-interest mailing list