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

Comparing jsr166/src/test/tck/AbstractQueuedSynchronizerTest.java (file contents):
Revision 1.9 by dl, Wed Jan 7 01:02:17 2004 UTC vs.
Revision 1.10 by dl, Wed Jan 7 20:49:53 2004 UTC

# Line 73 | Line 73 | public class AbstractQueuedSynchronizerT
73          public boolean isLocked() { return sync.isLocked(); }
74          public boolean hasQueuedThreads() { return sync.hasQueuedThreads(); }
75          public boolean hasContended() { return sync.hasContended(); }
76 +        public boolean isQueued(Thread t) { return sync.isQueued(t); }
77      }
78  
79      /**
# Line 149 | Line 150 | public class AbstractQueuedSynchronizerT
150              t1.join();
151              t2.join();
152          } catch(Exception e){
153 +            unexpectedException();
154 +        }
155 +    }
156 +
157 +    /**
158 +     * isQueued reports whether a thread is queued.
159 +     */
160 +    public void testIsQueued() {
161 +        final Mutex lock = new Mutex();
162 +        Thread t1 = new Thread(new InterruptedLockRunnable(lock));
163 +        Thread t2 = new Thread(new InterruptibleLockRunnable(lock));
164 +        try {
165 +            assertFalse(lock.isQueued(t1));
166 +            assertFalse(lock.isQueued(t2));
167 +            lock.lock();
168 +            t1.start();
169 +            Thread.sleep(SHORT_DELAY_MS);
170 +            assertTrue(lock.isQueued(t1));
171 +            t2.start();
172 +            Thread.sleep(SHORT_DELAY_MS);
173 +            assertTrue(lock.isQueued(t1));
174 +            assertTrue(lock.isQueued(t2));
175 +            t1.interrupt();
176 +            Thread.sleep(SHORT_DELAY_MS);
177 +            assertFalse(lock.isQueued(t1));
178 +            assertTrue(lock.isQueued(t2));
179 +            lock.unlock();
180 +            Thread.sleep(SHORT_DELAY_MS);
181 +            assertFalse(lock.isQueued(t1));
182 +            assertFalse(lock.isQueued(t2));
183 +            t1.join();
184 +            t2.join();
185 +        } catch(Exception e){
186              unexpectedException();
187          }
188      }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines