Proposals: Synchronization

Sean Kelly sean at f4.ca
Mon Jul 24 15:51:30 PDT 2006


Kent Boogaart wrote:
>> This would make this currently legal syntax illegal:
>>
>> void fn() {
>>     synchronized {
>>         // stuff
>>     }
>> }
>>
>> ie. where the synchronization object is implicit.  I suppose its value is 
>> debatable, but I think it's sufficiently useful that I wouldn't want it to 
>> be illegal.
> 
> I see that as a good thing, though. That is because the implicit syntax is 
> locking on this (I assume), which - as discussed - is a bad thing.

It will lock on the instance monitor (ie. 'this'), the static object 
monitor (ie. Classname.classinfo), or the global monitor, depending on 
context.

By the way, I agree that it's a Bad Idea to lock on an object that 
internally locks on 'this', but I'm not certain that it's something 
worth having the compiler enforce.


Sean



More information about the Digitalmars-d mailing list