final SomeData data = new SomeData();
data.write();
data.read();
QueueLock qlock = new MockQueueLock();
final ReadWriteLock locker = new DistributedReadWriteLock(qlock, "locker1".getBytes());
Lock readLock = locker.readLock();
Lock writeLock = locker.writeLock();
readLock.lock();
readLock.unlock();
writeLock.lock();
writeLock.unlock();
readLock.lock();
readLock.unlock();
// do a bunch of reads/writes in separate threads, look for inconsistent updates
Thread[] threads = new Thread[2];
for (int i = 0; i < threads.length; i++) {
final int which = i;
threads[i] = new Thread() {
public void run() {
if (which % 2 == 0) {
Lock wl = locker.writeLock();
wl.lock();
try {
data.write();
} finally {
wl.unlock();
}
} else {
Lock rl = locker.readLock();
rl.lock();
data.read();
try {
data.read();
} finally {