public void testDrainTasksTo(){
  final CountDownLatch done=new CountDownLatch(1);
  SubFJP p=new SubFJP();
  PoolCleaner cleaner=null;
  try {
    cleaner=cleaner(p);
    ForkJoinTask<?> a=p.submit(awaiter(done));
    ForkJoinTask<?> b=p.submit(awaiter(done));
    ForkJoinTask<?> c=p.submit(awaiter(done));
    ArrayList<ForkJoinTask<?>> al=new ArrayList();
    p.drainTasksTo(al);
    assertTrue(al.size() > 0);
    for (    ForkJoinTask<?> r : al) {
      assertTrue(r == a || r == b || r == c);
      assertFalse(r.isDone());
    }
    done.countDown();
  }
  finally {
    if (cleaner != null) {
      cleaner.close();
    }
  }
}

public void testDrainTasksTo ( ) { final CountDownLatch done = new CountDownLatch ( 1 ) ; SubFJP p = new SubFJP ( ) ; PoolCleaner cleaner = null ; try { cleaner = cleaner ( p ) ; ForkJoinTask < ? > a = p . submit ( awaiter ( done ) ) ; ForkJoinTask < ? > b = p . submit ( awaiter ( done ) ) ; ForkJoinTask < ? > c = p . submit ( awaiter ( done ) ) ; ArrayList < ForkJoinTask < ? > > al = new ArrayList ( ) ; p . drainTasksTo ( al ) ; assertTrue ( al . size ( ) > 0 ) ; for ( ForkJoinTask < ? > r : al ) { assertTrue ( r == a || r == b || r == c ) ; assertFalse ( r . isDone ( ) ) ; } done . countDown ( ) ; } finally { if ( cleaner != null ) { cleaner . close ( ) ; } } }
draintasksto transfers unexecuted submitted tasks , if present
