2 ms·
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 the
by raducu 6y ago
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.
- jayd16 6y ago>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){}