Re:Discipline Doesn’t Scale
by jayd16 on Wednesday October 21, 2020 @03:58AM
(#24845694)
I thought Java's locking worked fine as long as you didn't make your locks public or lock on `this`. What is Rust doing that's an improvement?
[ Parent
| on HN ]
What is wrong with locking on "this" ?
Making the locks public, I sort of get (like making any field public) -- you have multiple locks, you need to ensure they are accessed in a certain order and if you make them public, you cannot enforce that order.
>What is wrong with locking on "this" ?
Instance.this is implicitly public because something else could have a reference to instance.
synchronize(this){}
that will lock with the following if its inside instance. synchronize(instance){}