...
Code Block | ||
---|---|---|
| ||
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.
...