You can schedule multiple tasks on the timer. Each task is run by the same timer thread though, so the tasks should be short. If they're not, they can back up the timer.
Different Timer object for new Task?
Вопрос
I use
timer.schedule(new DoReassignement(), delay, controlInterval);
And want to add
timer.scheduleAtFixedRate(fetchMail, getTomorrowMorning4am(), fONCE_PER_DAY);
Should I use different Timer object for new task or I shouldnt ? Thanks in advance.
Edit: my tasks sometimes could be(and should be) executed at the same time, but I dont want for each of them to delay or wait.
Решение
Другие советы
You can reuse a timer for multiple tasks. It'll only throw an IllegalStateException
if you attempt to schedule the same task 2x
Не связан с StackOverflow