WriteLocker writeLocker = new WriteLocker(_lock, this, TWO_SECONDS);
Thread t3 = new Thread(writeLocker);
- t1.start(); // acquire read lock
+ t1.start(); // acquire read lock [0, 2.5]
Thread.sleep(ONE_SECOND);
+ // t = 1
assertTrue(getReaderCount() == 1);
- t2.start();
+ t2.start(); // acquire read lock [1, 3.5]
Thread.sleep(HALF_SECOND);
+ // t = 1.5
assertTrue(getReaderCount() == 2);
- t3.start();
+ t3.start(); // write lock
Thread.sleep(HALF_SECOND);
// 2 seconds,
// have been released.
assertTrue(getReaderCount() == 1);
assertTrue(getWriterCount() == 0);
- Thread.sleep(HALF_SECOND);
+ Thread.sleep(ONE_SECOND);
// 4 seconds underway, write lock must have
// been acquired.