ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/jsr166/jsr166/src/test/tck/ReentrantLockTest.java
(Generate patch)

Comparing jsr166/src/test/tck/ReentrantLockTest.java (file contents):
Revision 1.22 by dl, Tue May 3 16:02:00 2005 UTC vs.
Revision 1.24 by dl, Fri Feb 24 00:03:16 2006 UTC

# Line 409 | Line 409 | public class ReentrantLockTest extends J
409          Thread t = new Thread(new InterruptedLockRunnable(lock));
410          try {
411              t.start();
412 +            Thread.sleep(SHORT_DELAY_MS);
413              t.interrupt();
414              lock.unlock();
415              t.join();
# Line 1043 | Line 1044 | public class ReentrantLockTest extends J
1044                          lock.unlock();
1045                      }
1046                      catch(InterruptedException e) {
1047 +                        threadUnexpectedException();
1048 +                    }
1049 +                }
1050 +            });
1051 +
1052 +        try {
1053 +            t1.start();
1054 +            t2.start();
1055 +            Thread.sleep(SHORT_DELAY_MS);
1056 +            lock.lock();
1057 +            c.signalAll();
1058 +            lock.unlock();
1059 +            t1.join(SHORT_DELAY_MS);
1060 +            t2.join(SHORT_DELAY_MS);
1061 +            assertFalse(t1.isAlive());
1062 +            assertFalse(t2.isAlive());
1063 +        }
1064 +        catch (Exception ex) {
1065 +            unexpectedException();
1066 +        }
1067 +    }
1068 +
1069 +    /**
1070 +     * await after multiple reentrant locking preserves lock count
1071 +     */
1072 +    public void testAwaitLockCount() {
1073 +        final ReentrantLock lock = new ReentrantLock();
1074 +        final Condition c = lock.newCondition();
1075 +        Thread t1 = new Thread(new Runnable() {
1076 +                public void run() {
1077 +                    try {
1078 +                        lock.lock();
1079 +                        threadAssertEquals(1, lock.getHoldCount());
1080 +                        c.await();
1081 +                        threadAssertEquals(1, lock.getHoldCount());
1082 +                        lock.unlock();
1083 +                    }
1084 +                    catch(InterruptedException e) {
1085 +                        threadUnexpectedException();
1086 +                    }
1087 +                }
1088 +            });
1089 +
1090 +        Thread t2 = new Thread(new Runnable() {
1091 +                public void run() {
1092 +                    try {
1093 +                        lock.lock();
1094 +                        lock.lock();
1095 +                        threadAssertEquals(2, lock.getHoldCount());
1096 +                        c.await();
1097 +                        threadAssertEquals(2, lock.getHoldCount());
1098 +                        lock.unlock();
1099 +                        lock.unlock();
1100 +                    }
1101 +                    catch(InterruptedException e) {
1102                          threadUnexpectedException();
1103                      }
1104                  }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines