Java Scheduled Executor: garantit-il de ne pas s'exécuter en parallèle si la tâche n'est pas encore terminée

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

  •  06-07-2019
  •  | 
  •  

Question

Quelqu'un sait-il si la méthode Java suivante dans le package java.util.concurrent ScheduledExecutorService.html # scheduleAtFixedRate ()

garantit absolument que le programme Runnable programmé ne sera jamais exécuté en parallèle au cas où le fichier runnable de la "dernière" sera utilisé. la course ne s'est pas encore terminée:

Par exemple (pseudocode)

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.

Merci beaucoup Jan

Était-ce utile?

La solution

De la docs :

  

Si l'exécution de cette tâche prend   plus long que sa période, alors   les exécutions ultérieures peuvent commencer tardivement,   mais ne sera pas exécuté simultanément.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top