プログラムのスケジューリングに cron4j ライブラリを使用しています。これが私のコードです:
public class Main {
public static void main(String[] args) {
// Declares the file.
File file = new File("cron4j.txt");
// Creates the scheduler.
Scheduler scheduler = new Scheduler();
// Schedules the file.
scheduler.scheduleFile(file);
// Starts the scheduler.
scheduler.start();
// Stays alive for five minutes.
try {
Thread.sleep(5L * 60L * 1000L);
} catch (InterruptedException e) {
;
}
// Stops the scheduler.
scheduler.stop();
}
}
「cron4j.txt」ファイル内で、プログラムを毎分実行するように設定しました。
- ファイル内のプログラムを毎分実行するには、オブジェクト スケジューラを含むこのファイル (クラス Main) を実行する必要がありますか?
- または、これを 1 回実行すると、スケジューラはこのジョブをオペレーティング システムに渡しますか?