Java agendada Executor: Será que garantem não correr em paralelo se a tarefa ainda não terminou

StackOverflow https://stackoverflow.com/questions/1632371

  •  06-07-2019
  •  | 
  •  

Pergunta

Alguém sabe se o seguinte java Método na java.util.concurrent pacote ScheduledExecutorService.html#scheduleAtFixedRate()

absolutamente garantias, que o Runnable programada nunca funcionará em paralelo no caso do executável a partir da "última" corrida ainda não terminou:

Por exemplo (Pseudocódigo)

1.00 o'clock: scheduleAtFixedRate(MyRunnable, "Run ever Hour")`
//1.30 o'clock: MyRunnable Has finished (everthing is fine)
2.00 o'clock: MyRunnable is triggered to run again
3.00 o'clock: MyRunnable has NOT yet finished ==> What will happen here? 
Will java Simply SKIP the starting of MyRunnable (as the old instance has not yet 
finished) and try again at 4 o'clock or will Java start a NEW MyRunnable that then will 
run in parallel to the "old" MyRunnable.

Muito obrigado Jan

Foi útil?

Solução

do docs :

Se qualquer execução desta tarefa leva mais do que o seu período, em seguida, execuções subsequentes podem começar tarde, mas não simultaneamente executar.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top