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

Comparing jsr166/src/test/tck/ForkJoinPoolTest.java (file contents):
Revision 1.39 by dl, Fri May 6 11:22:07 2011 UTC vs.
Revision 1.40 by jsr166, Sun May 15 17:32:29 2011 UTC

# Line 251 | Line 251 | public class ForkJoinPoolTest extends JS
251      }
252  
253      /**
254 <     * After invoking a single task, isQuiescent is true,
255 <     * queues are empty, threads are not active, and
256 <     * construction parameters continue to hold
254 >     * After invoking a single task, isQuiescent eventually becomes
255 >     * true, at which time queues are empty, threads are not active,
256 >     * the task has completed successfully, and construction
257 >     * parameters continue to hold
258       */
259 <    public void testisQuiescent() throws InterruptedException {
259 >    public void testisQuiescent() throws Exception {
260          ForkJoinPool p = new ForkJoinPool(2);
261          try {
262              assertTrue(p.isQuiescent());
263 <            p.invoke(new FibTask(20));
263 >            long startTime = System.nanoTime();
264 >            FibTask f = new FibTask(20);
265 >            p.invoke(f);
266              assertSame(ForkJoinPool.defaultForkJoinWorkerThreadFactory,
267                         p.getFactory());
268 <            delay(SMALL_DELAY_MS);
268 >            while (! p.isQuiescent()) {
269 >                if (millisElapsedSince(startTime) > LONG_DELAY_MS)
270 >                    throw new AssertionFailedError("timed out");
271 >                assertFalse(p.getAsyncMode());
272 >                assertFalse(p.isShutdown());
273 >                assertFalse(p.isTerminating());
274 >                assertFalse(p.isTerminated());
275 >                Thread.yield();
276 >            }
277 >
278              assertTrue(p.isQuiescent());
279              assertFalse(p.getAsyncMode());
280              assertEquals(0, p.getActiveThreadCount());
# Line 272 | Line 284 | public class ForkJoinPoolTest extends JS
284              assertFalse(p.isShutdown());
285              assertFalse(p.isTerminating());
286              assertFalse(p.isTerminated());
287 +            assertTrue(f.isDone());
288 +            assertEquals(6765, (int) f.get());
289          } finally {
290              joinPool(p);
291          }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines