List of usage examples for java.util.concurrent ScheduledFuture cancel
boolean cancel(boolean mayInterruptIfRunning);
From source file:edu.umich.robot.util.SimBattery.java
public void stop() { ScheduledFuture<?> t = updateTask.getAndSet(null); if (t != null) t.cancel(false); }
From source file:org.apache.archiva.indexer.merger.DefaultMergedRemoteIndexesScheduler.java
@Override public void unschedule(RepositoryGroup repositoryGroup) { ScheduledFuture scheduledFuture = scheduledFutureMap.remove(repositoryGroup.getId()); if (scheduledFuture != null) { scheduledFuture.cancel(true); }/*from www . ja v a2 s. co m*/ }
From source file:com.ah.be.license.AeroLicenseTimer.java
/** * Stop your defined license timer./*from www . j a v a 2s . com*/ * * @param arg_Timer - * @param arg_Future - * @return String : the error message */ public static String stopLicenseTimer(ScheduledExecutorService arg_Timer, ScheduledFuture<?> arg_Future) { try { if (!arg_Timer.isShutdown()) { if (null != arg_Future) { arg_Future.cancel(false); } // Disable new tasks from being submitted. arg_Timer.shutdown(); try { // Wait a while for existing tasks to terminate. if (!arg_Timer.awaitTermination(5, TimeUnit.SECONDS)) { // Cancel currently executing tasks. arg_Timer.shutdownNow(); // Wait a while for tasks to respond to being canceled. if (!arg_Timer.awaitTermination(5, TimeUnit.SECONDS)) { return "The license timer does not terminate."; } } } catch (InterruptedException ie) { // (Re-)Cancel if current thread also interrupted. //arg_Timer.shutdownNow(); } } } catch (Exception e) { return "There is something wrong with timer stop."; } return null; }
From source file:org.apache.james.fetchmail.FetchScheduler.java
@PreDestroy public void dispose() { if (enabled) { logger.info("FetchMail dispose..."); for (ScheduledFuture<?> scheduler1 : schedulers) { scheduler1.cancel(false); }//w ww .ja v a2 s . co m logger.info("FetchMail ...dispose end"); } }
From source file:com.bfd.harpc.heartbeat.HeartBeatManager.java
/** * ?heartbeat/*www . j a v a2s. c o m*/ * <p> */ public void stopHeartbeatTimer() { try { ScheduledFuture<?> timer = heatbeatTimer; if (timer != null && !timer.isCancelled()) { timer.cancel(true); } } catch (Throwable t) { LOGGER.warn(t.getMessage(), t); } finally { heatbeatTimer = null; } }
From source file:com.github.mrstampy.gameboot.otp.processor.OtpNewKeyRegistry.java
/** * Removes the newly generated key for activation. * * @param key//from w w w . j a va 2 s . com * the key * @return the byte[] */ @Override public byte[] remove(AbstractRegistryKey<?> key) { byte[] b = super.remove(key); ScheduledFuture<?> sf = futures.remove(key); if (sf != null) sf.cancel(true); return b; }
From source file:ru.jts_dev.gameserver.movement.MovementService.java
public void stopMovement(final GameCharacter character) { ScheduledFuture<?> future = tasks.remove(character.getObjectId()); if (future != null) { future.cancel(true); }/*from w w w. j a v a 2s . c o m*/ }
From source file:com.github.mrstampy.gameboot.otp.processor.OtpNewKeyRegistry.java
/** * Puts the newly generated key paired against the {@link SystemId#next()} id * value of the clear connection.// w ww .j ava 2 s.c o m * * @param key * the key * @param value * the value */ @Override public void put(AbstractRegistryKey<?> key, byte[] value) { ScheduledFuture<?> sf = futures.remove(key); if (sf != null) sf.cancel(true); super.put(key, value); sf = svc.schedule(() -> cleanup(key), newKeyExpiry, TimeUnit.SECONDS); futures.put(key, sf); }
From source file:com.github.mrstampy.gameboot.web.HttpSessionRegistry.java
private void stopCleanup(AbstractRegistryKey<?> key) { ScheduledFuture<?> sf = futures.remove(key); if (sf != null) sf.cancel(true); }
From source file:com.github.mrstampy.gameboot.web.HttpSessionRegistry.java
private void scheduleCleanup(AbstractRegistryKey<?> key, HttpSession value) { ScheduledFuture<?> sf = futures.remove(key); if (sf != null) sf.cancel(true); super.put(key, value); sf = svc.schedule(() -> cleanup(key, value), expiry, TimeUnit.SECONDS); futures.put(key, sf);/* w w w .j a v a 2 s .c o m*/ }