2

java.util.concurrent パッケージの次の Java メソッドがScheduledExecutorService.html#scheduleAtFixedRate()

「最後の」実行からの実行可能ファイルがまだ終了していない場合に、スケジュールされた実行可能ファイルが並行して実行されないことを絶対に保証します。

たとえば(疑似コード)

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.

どうもありがとうジャン

4

1 に答える 1

2

ドキュメントから:

このタスクの実行にその期間よりも時間がかかる場合、後続の実行は遅れて開始される可能性がありますが、同時に実行されることはありません。

于 2009-10-27T17:31:26.360 に答える