I need to schedule some work to be done in the future. I can do it in 2 ways:
Create a
TimerTask
and executetimer.schedule(...);
Use
Executors.newScheduledThreadPool(1)
:ScheduledExecutorService scheduler = Executors.newScheduledThreadPool(1); ScheduledFuture <?> scheduleHandle = scheduler.schedule(pushExternalRunnable, runScheduleDate.getTime() - now.getTime(), TimeUnit.MILLISECONDS);
What is the difference between these 2 ways of scheduling the work in the future?