< prev index next >

test/java/util/Timer/DelayOverflow.java

Print this page




  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  */
  23 
  24 /*
  25  * @test
  26  * @bug 6730507
  27  * @summary java.util.Timer schedule delay Long.MAX_VALUE causes task to execute multiple times
  28  * @author Chris Hegarty
  29  * @author Martin Buchholz

  30  */
  31 
  32 import java.util.Date;
  33 import java.util.Timer;
  34 import java.util.TimerTask;
  35 import java.util.concurrent.*;
  36 import java.util.concurrent.atomic.AtomicInteger;
  37 
  38 public class DelayOverflow
  39 {
  40     void scheduleNow(Timer timer, TimerTask task, int how) {
  41         switch (how) {
  42             case 0 :
  43                 timer.schedule(task, new Date(), Long.MAX_VALUE);
  44                 break;
  45             case 1:
  46                 timer.schedule(task, 0L, Long.MAX_VALUE);
  47                 break;
  48             case 2:
  49                 timer.scheduleAtFixedRate(task, new Date(), Long.MAX_VALUE);




  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  */
  23 
  24 /*
  25  * @test
  26  * @bug 6730507
  27  * @summary java.util.Timer schedule delay Long.MAX_VALUE causes task to execute multiple times
  28  * @author Chris Hegarty
  29  * @author Martin Buchholz
  30  * @key randomness
  31  */
  32 
  33 import java.util.Date;
  34 import java.util.Timer;
  35 import java.util.TimerTask;
  36 import java.util.concurrent.*;
  37 import java.util.concurrent.atomic.AtomicInteger;
  38 
  39 public class DelayOverflow
  40 {
  41     void scheduleNow(Timer timer, TimerTask task, int how) {
  42         switch (how) {
  43             case 0 :
  44                 timer.schedule(task, new Date(), Long.MAX_VALUE);
  45                 break;
  46             case 1:
  47                 timer.schedule(task, 0L, Long.MAX_VALUE);
  48                 break;
  49             case 2:
  50                 timer.scheduleAtFixedRate(task, new Date(), Long.MAX_VALUE);


< prev index next >