Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: do not lock on Lock and Condition implementers

...

Code Block
bgColor#FFcccc
final Lock lock = new ReentrantLock();
synchronized(lock) { /* ... */ }

Similarly, it is inappropriate to lock on an object of a class that implements either the Lock or Condition interface of package java.util.concurrent.locks. This problem usually comes up in practice when refactoring from intrinsic locking to the java.util.concurrent dynamic locking utilities.

...