Java Scheduled Executor: garantisce di non funzionare in parallelo se l'attività non è ancora terminata

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

  •  06-07-2019
  •  | 
  •  

Domanda

qualcuno sa se il seguente metodo java nel pacchetto java.util.concurrent ScheduledExecutorService.html#scheduleAtFixedRate()

garantisce assolutamente che il Runnable programmato non verrà mai eseguito in parallelo nel caso in cui il runnable dall'ultimo "quot" la corsa non è ancora terminata:

Ad esempio (Pseudocodice)

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.

Grazie mille Jan

È stato utile?

Soluzione

Dal docs :

  

Se l'esecuzione di questa attività richiede   più lungo del suo periodo, quindi   le esecuzioni successive potrebbero iniziare in ritardo,   ma non verrà eseguito contemporaneamente.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top