4 ms·
They're saying multiple things can synchronize on the same public field. Same reason you don't want to use this. Although I suppose they could mean the concep
by jayd16 2y ago
They're saying multiple things can synchronize on the same public field. Same reason you don't want to use this.
Although I suppose they could mean the concept and not the keyword. A field might not be thread safe and there's no way for an object to guarantee thread safe access of to a field.
- mrkeen 2y agoDeadlocking was raised as the objection to using public instead of getter. But in regard to deadlocking, using public is strictly better than a getter. You have to take a lock in order to deadlock in the public version. In the getter version, you can take a lock without realising it and then deadlock.