< prev index next >

test/jdk/java/util/concurrent/ScheduledThreadPoolExecutor/DelayOverflow.java

Print this page
rev 51731 : imported patch 8210732


  18  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  19  * or visit www.oracle.com if you need additional information or have any
  20  * questions.
  21  */
  22 
  23 /*
  24  * This file is available under and governed by the GNU General Public
  25  * License version 2 only, as published by the Free Software Foundation.
  26  * However, the following notice accompanied the original version of this
  27  * file:
  28  *
  29  * Written by Doug Lea with assistance from members of JCP JSR-166
  30  * Expert Group and released to the public domain, as explained at
  31  * http://creativecommons.org/publicdomain/zero/1.0/
  32  */
  33 
  34 /*
  35  * @test
  36  * @bug 6725789
  37  * @summary Check for long overflow in task time comparison.
  38  * @library /lib/testlibrary/
  39  */
  40 
  41 import static java.util.concurrent.TimeUnit.DAYS;
  42 import static java.util.concurrent.TimeUnit.MILLISECONDS;
  43 import static java.util.concurrent.TimeUnit.NANOSECONDS;
  44 
  45 import java.util.concurrent.CountDownLatch;
  46 import java.util.concurrent.Executors;
  47 import java.util.concurrent.ScheduledThreadPoolExecutor;
  48 import jdk.testlibrary.Utils;
  49 
  50 public class DelayOverflow {
  51     static final long LONG_DELAY_MS = Utils.adjustTimeout(10_000);
  52 
  53     static void waitForNanoTimeTick() {
  54         for (long t0 = System.nanoTime(); t0 == System.nanoTime(); )
  55             ;
  56     }
  57 
  58     void scheduleNow(ScheduledThreadPoolExecutor pool,
  59                      Runnable r, int how) {
  60         switch (how) {
  61         case 0:
  62             pool.schedule(r, 0, MILLISECONDS);
  63             break;
  64         case 1:
  65             pool.schedule(Executors.callable(r), 0, DAYS);
  66             break;
  67         case 2:
  68             pool.scheduleWithFixedDelay(r, 0, 1000, NANOSECONDS);




  18  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  19  * or visit www.oracle.com if you need additional information or have any
  20  * questions.
  21  */
  22 
  23 /*
  24  * This file is available under and governed by the GNU General Public
  25  * License version 2 only, as published by the Free Software Foundation.
  26  * However, the following notice accompanied the original version of this
  27  * file:
  28  *
  29  * Written by Doug Lea with assistance from members of JCP JSR-166
  30  * Expert Group and released to the public domain, as explained at
  31  * http://creativecommons.org/publicdomain/zero/1.0/
  32  */
  33 
  34 /*
  35  * @test
  36  * @bug 6725789
  37  * @summary Check for long overflow in task time comparison.
  38  * @library /test/lib
  39  */
  40 
  41 import static java.util.concurrent.TimeUnit.DAYS;
  42 import static java.util.concurrent.TimeUnit.MILLISECONDS;
  43 import static java.util.concurrent.TimeUnit.NANOSECONDS;
  44 
  45 import java.util.concurrent.CountDownLatch;
  46 import java.util.concurrent.Executors;
  47 import java.util.concurrent.ScheduledThreadPoolExecutor;
  48 import jdk.test.lib.Utils;
  49 
  50 public class DelayOverflow {
  51     static final long LONG_DELAY_MS = Utils.adjustTimeout(10_000);
  52 
  53     static void waitForNanoTimeTick() {
  54         for (long t0 = System.nanoTime(); t0 == System.nanoTime(); )
  55             ;
  56     }
  57 
  58     void scheduleNow(ScheduledThreadPoolExecutor pool,
  59                      Runnable r, int how) {
  60         switch (how) {
  61         case 0:
  62             pool.schedule(r, 0, MILLISECONDS);
  63             break;
  64         case 1:
  65             pool.schedule(Executors.callable(r), 0, DAYS);
  66             break;
  67         case 2:
  68             pool.scheduleWithFixedDelay(r, 0, 1000, NANOSECONDS);


< prev index next >