synchronized { }

Steven Schveighoffer schveiguy at yahoo.com
Fri Jun 27 08:47:56 PDT 2008


"torhu" wrote
> Steven Schveighoffer wrote:
>> In any case, Tango avoids needing this statement by making mutexes fully 
>> accessible objects.  If you need a mutex without having it attached to an 
>> object, it's easy:
>>
>> Mutex m = new Mutex;
>>
>> synchronized(m)
>> {
>> }
>
>
> Isn't that the same as doing this?
>
> ---
> Object m = new Object;
>
> synchronized(m)
> {
> }

It's close, but in Tango, you have methods for the mutex, plus you can use 
them with conditions.

Plus, it's not as hackish :)

It would be nice if the language supported conditions based on the Monitor 
object by default.

-Steve 





More information about the Digitalmars-d mailing list