public static void lockWrite(ReentrantReadWriteLock lock,
long timeout)
{
if (lock.getReadHoldCount() > 0
&& lock.getWriteHoldCount() == 0) {
throw new IllegalLoopbackException(L.l("Cannot attempt a nested write lock without an existing write lock."));
}
try {
if (! lock.writeLock().tryLock(timeout, TimeUnit.MILLISECONDS))
throw new ConcurrentAccessTimeoutException(L.l("Timed out acquiring write lock."));