@Override public void increment() { long stamp = stampedLock.writeLock(); // blocking lock, returns a stamp try { counter++; } finally { stampedLock.unlockWrite(stamp); // release the lock in the same block } }