### Question:
PidLockManager { public Lock awaitWriteLock(PID pid) { try { Lock lock = lockPid(pid).writeLock(); lock.lockInterruptibly(); return lock; } catch (InterruptedException e) { throw new InterruptedLockException("Interrupted while waiting for lock on " + pid.getQualifiedId()); } } PidLockManager();  PidLockManager(int numLocks); static PidLockManager getDefaultPidLockManager(); ReadWriteLock lockPid(PID pid); Lock awaitWriteLock(PID pid); Lock awaitReadLock(PID pid);  }### Answer:
@Test public void awaitWriteLockThenWriteLock() throws Exception { Lock outerLock = lockManager.awaitWriteLock(pid); Thread thread = new Thread(() -> { lockManager.awaitWriteLock(pid); }); thread.start(); Thread.sleep(25); assertTrue(thread.isAlive()); outerLock.unlock(); Thread.sleep(25); assertFalse(thread.isAlive()); }