From: erik Date: Sun, 15 Feb 2009 16:10:15 +0000 (+0000) Subject: found an error in the junit test after a long time X-Git-Tag: wamblee-utils-0.2~1^2~68 X-Git-Url: http://wamblee.org/gitweb/?a=commitdiff_plain;h=4ad098103dce0d129f2019cb349e90c0fbca84ee;hp=e4d0b3d00494106ef641eb53bdb8789ca8cb9ca4;p=utils found an error in the junit test after a long time --- diff --git a/support/general/src/test/java/org/wamblee/concurrency/ReadWriteLockTest.java b/support/general/src/test/java/org/wamblee/concurrency/ReadWriteLockTest.java index 2c159e94..40302f76 100644 --- a/support/general/src/test/java/org/wamblee/concurrency/ReadWriteLockTest.java +++ b/support/general/src/test/java/org/wamblee/concurrency/ReadWriteLockTest.java @@ -220,13 +220,15 @@ public class ReadWriteLockTest extends TestCase { 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, @@ -238,7 +240,7 @@ public class ReadWriteLockTest extends TestCase { // 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.