super(ZooReaderWriter.getRetryingInstance(), path, ephemeral);
}
public static void main(String args[]) throws InterruptedException, KeeperException {
ZooQueueLock lock = new ZooQueueLock("/lock", true);
DistributedReadWriteLock rlocker = new DistributedReadWriteLock(lock, "reader".getBytes(Constants.UTF8));
DistributedReadWriteLock wlocker = new DistributedReadWriteLock(lock, "wlocker".getBytes(Constants.UTF8));
final Lock readLock = rlocker.readLock();
readLock.lock();
final Lock readLock2 = rlocker.readLock();
readLock2.lock();
final Lock writeLock = wlocker.writeLock();
if (writeLock.tryLock(100, TimeUnit.MILLISECONDS))
throw new RuntimeException("Write lock achieved during read lock!");
readLock.unlock();
readLock2.unlock();
writeLock.lock();