private Future<T> doSchedule( long nextTime ) { return getScheduler().getScheduledExecutorService().schedule( this, Math.max( 0, nextTime - System.currentTimeMillis() ), TimeUnit.MILLISECONDS ); }
private Future<T> doSchedule(final long nextTime, final boolean inheritContext) { // FIXME: All this coz MDCUtils are in Core, while // scheduler is a module ahead. If scheduler would // be in core, this would not be needed, but instead // MDCUtils.markCurrentContextNonInheritable() call would do it if (!inheritContext) { MDC.put("non-inheritable", "non-inheritable"); } try { return getScheduler().getScheduledExecutorService().schedule(this, Math.max(0, nextTime - System.currentTimeMillis()), TimeUnit.MILLISECONDS); } finally { if (!inheritContext) { MDC.remove("non-inheritable"); } } }
public void shutdown() { getLogger().info( "Shutting down Scheduler..." ); getScheduledExecutorService().shutdown(); try { boolean stopped = getScheduledExecutorService().awaitTermination( 1, TimeUnit.SECONDS ); if ( !stopped ) { final Map<String, List<ScheduledTask<?>>> runningTasks = getRunningTasks(); if ( !runningTasks.isEmpty() ) { getScheduledExecutorService().shutdownNow(); getLogger().warn( "Scheduler shut down forcibly with tasks running." ); } else { getLogger().info( "Scheduler shut down cleanly with tasks scheduled." ); } } } catch ( InterruptedException e ) { getLogger().info( "Termination interrupted", e ); } }
setFuture(getScheduler().getScheduledExecutorService().schedule(this, 10000, TimeUnit.MILLISECONDS));
setFuture( getScheduler().getScheduledExecutorService().schedule( this, 10000, TimeUnit.MILLISECONDS ) );