Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Code Block
bgColor#ccccff
public void doSomething() {
  final Lock lock = new ReentrantLock();
  lock.lock();
  try {
    // ...
  } finally {
    lock.unlock();
  }
  // perform some time consuming operation
}

Risk Assessment

Failing to release a lock on an exceptional condition may lead to thread starvation and deadlock.

...