synchronized - shared but actually useful
FeepingCreature
feepingcreature at gmail.com
Fri Jul 1 07:13:23 UTC 2022
On Wednesday, 31 October 2018 at 10:36:35 UTC, FeepingCreature
wrote:
> On Wednesday, 31 October 2018 at 10:25:52 UTC, Jonathan M Davis
> wrote:
>> synchronized classes really only protect the stuff that sit
>> directly inside the class itself, not what the class' member
>> variables refer to. If they were to fully protect everything
>> inside of it, then you couldn't really pass anything in or out
>> of it.
>>
>> - Jonathan M Davis
>
> You could pass other synchronized objects, immutable data and
> data by value.
>
> In many project designs, that's really all you need.
Apropos of running into a production threading error that would
have been fixed by this synchronized proposal, let me just bump
this thread to note that it's four years later and this code
still fails to compile for absolutely zero reason:
```
synchronized class A
{
private int e;
void foo() { e++; }
}
```
More information about the Digitalmars-d
mailing list