SimpleTimerTask (@NotNull final Runnable runnable, final long delay) { final ScheduledFuture<?> future = myScheduledExecutorService.schedule(runnable, delay, TimeUnit.MILLISECONDS); return new SimpleTimerTask() { @Override public void cancel() { future.cancel(false); } @Override public boolean isCancelled() { return future.isCancelled(); } }; }