synchronized { }

Sean Kelly sean at invisibleduck.org
Mon Jun 30 15:01:30 PDT 2008


== Quote from torhu (no at spam.invalid)'s article
> Sean Kelly wrote:
> > == Quote from Graham St Jack (graham.stjack at internode.on.net)'s article
> >> On Thu, 26 Jun 2008 08:15:24 -0400, Michel Fortin wrote:
> >> > On 2008-06-25 21:18:41 -0400, Walter Bright <newshound1 at digitalmars.com>
> >> > said:
> >> >
> >> >> Right now, if you use a synchronized statement with no argument, it
> >> >> will sync on a mutex unique to that statement.
> >> >>
> >> >> Does anyone write threading code that depends on this behavior?
> >> >
> >> > I've used it before, thinking it was equivalent to synchronize(this) {},
> >> > an incorrect assumption obviously. If you get rid of it, I won't miss
> >> > it.
> >> Same.
> >
> > Um, it /is/ equivalent to synchronized(this).  What made you think differently?
> >
> Don't the docs say that they're not equivalent?
> http://www.digitalmars.com/d/2.0/statement.html#SynchronizedStatement
> I thought they were the same too, before Walter checked in something to
> phobos that made me think otherwise.  Can't remember what exactly.

They're identical, unless something changed recently in D 2.0.  Walter confirmed
this explicitly for me a while back, though I don't have a link handy.


Sean



More information about the Digitalmars-d mailing list