[cvs] / jsr166 / src / test / tck / FutureTaskTest.java Repository:
ViewVC logotype

Diff of /jsr166/src/test/tck/FutureTaskTest.java

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.38, Wed Jun 19 05:54:45 2013 UTC revision 1.39, Fri Aug 22 03:30:56 2014 UTC
# Line 10  Line 10 
10  import java.util.concurrent.Callable;  import java.util.concurrent.Callable;
11  import java.util.concurrent.CancellationException;  import java.util.concurrent.CancellationException;
12  import java.util.concurrent.CountDownLatch;  import java.util.concurrent.CountDownLatch;
13    import java.util.concurrent.ExecutorService;
14    import java.util.concurrent.Executors;
15  import java.util.concurrent.ExecutionException;  import java.util.concurrent.ExecutionException;
16  import java.util.concurrent.Future;  import java.util.concurrent.Future;
17  import java.util.concurrent.FutureTask;  import java.util.concurrent.FutureTask;
18  import java.util.concurrent.TimeoutException;  import java.util.concurrent.TimeoutException;
19  import java.util.concurrent.atomic.AtomicInteger;  import java.util.concurrent.atomic.AtomicInteger;
20  import static java.util.concurrent.TimeUnit.MILLISECONDS;  import static java.util.concurrent.TimeUnit.*;
 import static java.util.concurrent.TimeUnit.SECONDS;  
21  import java.util.*;  import java.util.*;
22    
23  public class FutureTaskTest extends JSR166TestCase {  public class FutureTaskTest extends JSR166TestCase {
# Line 801  Line 802 
802          }          }
803      }      }
804    
805        /**
806         * timed get with most negative timeout works correctly (i.e. no
807         * underflow bug)
808         */
809        public void testGet_NegativeInfinityTimeout() throws Exception {
810            final ExecutorService pool = Executors.newFixedThreadPool(10);
811            final Runnable nop = new Runnable() { public void run() {}};
812            final FutureTask<Void> task = new FutureTask<>(nop, null);
813            final List<Future<?>> futures = new ArrayList<>();
814            Runnable r = new Runnable() { public void run() {
815                for (long timeout : new long[] { 0L, -1L, Long.MIN_VALUE }) {
816                    try {
817                        task.get(timeout, NANOSECONDS);
818                        shouldThrow();
819                    } catch (TimeoutException success) {
820                    } catch (Throwable fail) {threadUnexpectedException(fail);}}}};
821            for (int i = 0; i < 10; i++)
822                futures.add(pool.submit(r));
823            try {
824                joinPool(pool);
825                for (Future<?> future : futures)
826                    checkCompletedNormally(future, null);
827            } finally {
828                task.run();         // last resort to help terminate
829            }
830        }
831    
832  }  }

Legend:
Removed from v.1.38  
changed lines
  Added in v.1.39

Doug Lea
ViewVC Help
Powered by ViewVC 1.0.8