On Mon, Nov 12, 2001 at 03:48:38PM -0500, Gianni Johansson wrote:
> On Monday 12 November 2001 14:56, you wrote:
> > On Mon, Nov 12, 2001 at 03:06:33PM -0500, Gianni Johansson wrote:
> > > There are unlocked reads and writes of runningCount in several places.
> > > This looks like a race condition to me. Remember that ++ and -- are not
> > > guaranteed to be atomic.
> >
> > runningCount is volatile so you don't have to worry about ++ and --
> Making an int volatile only guarantees that atomic operations will be
> consistent across multiple threads, but ++ and -- are not atomic operations.
Alright, I had thought volatiles gave you slightly stronger guarantees ..
of course they are not atomic.
It's worth noting that there's still no need to synchronize just to read
the value of the variable. And runningCount doesn't need to be volatile
anymore :)
--
:: tavin cole (tcole at espnow.com) ::
if there's been a way to build it
there'll be a way to destroy it
things are not all that out of control
- stereolab
_______________________________________________
Devl mailing list
Devl at freenetproject.org
http://lists.freenetproject.org/mailman/listinfo/devl