I have:
private final ScheduledExecutorService executorService = Executors.newSingleThreadScheduledExecutor();
that runs a runnable task:
executorService.scheduleAtFixedRate(task, 0, 1, TimeUnit.SECONDS);
But it appears that executorService
doesn't have a cancel method (wtf, why?), shutting it down isn't an option and I'm doing something fairly simple so using Executors.newScheduledThreadPool
(which does have cancel()
) is a bit of an overkill.
Is there a way to properly stop the execution of the task?
PS: I searched before I asked and I really don't think this hack is the correct way.