private final Lock lock = new ReentrantLock();
public void process() {
try {
if (lock.tryLock()) {
// ...
lock.unlock();;
}
} finally {
lock.unlock();
}
}