src/share/classes/java/util/concurrent/ScheduledThreadPoolExecutor.java

Print this page

        

*** 60,71 **** * this, set {@link #setRemoveOnCancelPolicy} to {@code true}, which * causes tasks to be immediately removed from the work queue at * time of cancellation. * * <p>Successive executions of a task scheduled via ! * <code>scheduleAtFixedRate</code> or ! * <code>scheduleWithFixedDelay</code> do not overlap. While different * executions may be performed by different threads, the effects of * prior executions <a * href="package-summary.html#MemoryVisibility"><i>happen-before</i></a> * those of subsequent ones. * --- 60,71 ---- * this, set {@link #setRemoveOnCancelPolicy} to {@code true}, which * causes tasks to be immediately removed from the work queue at * time of cancellation. * * <p>Successive executions of a task scheduled via ! * {@code scheduleAtFixedRate} or ! * {@code scheduleWithFixedDelay} do not overlap. While different * executions may be performed by different threads, the effects of * prior executions <a * href="package-summary.html#MemoryVisibility"><i>happen-before</i></a> * those of subsequent ones. *
*** 358,369 **** BlockingQueue<Runnable> q = super.getQueue(); boolean keepDelayed = getExecuteExistingDelayedTasksAfterShutdownPolicy(); boolean keepPeriodic = getContinueExistingPeriodicTasksAfterShutdownPolicy(); ! if (!keepDelayed && !keepPeriodic) q.clear(); else { // Traverse snapshot to avoid iterator exceptions for (Object e : q.toArray()) { if (e instanceof RunnableScheduledFuture) { RunnableScheduledFuture<?> t = --- 358,373 ---- BlockingQueue<Runnable> q = super.getQueue(); boolean keepDelayed = getExecuteExistingDelayedTasksAfterShutdownPolicy(); boolean keepPeriodic = getContinueExistingPeriodicTasksAfterShutdownPolicy(); ! if (!keepDelayed && !keepPeriodic) { ! for (Object e : q.toArray()) ! if (e instanceof RunnableScheduledFuture<?>) ! ((RunnableScheduledFuture<?>) e).cancel(false); q.clear(); + } else { // Traverse snapshot to avoid iterator exceptions for (Object e : q.toArray()) { if (e instanceof RunnableScheduledFuture) { RunnableScheduledFuture<?> t =