Synchronized classes have no public members
ponce via Digitalmars-d
digitalmars-d at puremagic.com
Tue Oct 13 02:36:22 PDT 2015
On Tuesday, 13 October 2015 at 09:07:54 UTC, Chris wrote:
> On Tuesday, 13 October 2015 at 08:55:26 UTC, Benjamin Thaut
> wrote:
>>
>> I have to agree here. I think synchronized classes are of very
>> little use, especially because they don't "cast away" shared
>> in a useful way. It still has to be done manually. I think we
>> should remove them. Synchronized methods should also be
>> removed in my eyes. Making each and every object bigger by one
>> pointer just for the sake of a few synchronized methods
>> doesn't seem to be a good trade off to me. The entire
>> synchronized methods give the user the feeling that he simply
>> slaps synchronized on his class / method and then its thread
>> safe and he doesn't have to care about threads anymore. In the
>> real world this is far from true however. So synchronized
>> methods and classes just give a false sense of thread safety
>> and should rather be removed.
>
> Actually, I once fell foul of this wrong impression of thread
> safety via 'synchronized'. I found a different solution and
> dropped synchronized.
I also dropped synchronized and use @nogc mutexes instead. I also
think synchronized methods should be removed. It's also difficult
to explain: what is a "monitor"? when you write a synchronized {
} block, which monitor is taken?
More information about the Digitalmars-d
mailing list