Ejecutor programado de Java: ¿garantiza no ejecutarse en paralelo si la tarea aún no ha finalizado?

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

  •  06-07-2019
  •  | 
  •  

Pregunta

¿Alguien sabe si el siguiente Método java en el Paquete java.util.concurrent ScheduledExecutorService.html#scheduleAtFixedRate()

garantiza absolutamente que el Runnable programado nunca se ejecutará en paralelo en caso de que el ejecutable desde el " último " la ejecución aún no terminó:

Por ejemplo (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.

Muchas gracias Jan

¿Fue útil?

Solución

De docs :

  

Si alguna ejecución de esta tarea toma   más largo que su período, entonces   ejecuciones posteriores pueden comenzar tarde,   pero no se ejecutará simultáneamente.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top