开发者

Quartz scheduler shutdown(true) wait for all threads started from running Jobs to stop?

开发者 https://www.devze.com 2023-02-04 12:16 出处:网络
If I have a job and from开发者_StackOverflow中文版 that job I create some threads, what happens when I call scheduler.shutdown(true)?

If I have a job and from开发者_StackOverflow中文版 that job I create some threads, what happens when I call scheduler.shutdown(true)?

Will the scheduler wait for all of my threads to finish or not?


Quartz 1.8.1 API docs:

Halts the Scheduler's firing of Triggers, and cleans up all resources associated with the Scheduler.

Parameters: waitForJobsToComplete - if true the scheduler will not allow this method to return until all currently executing jobs have completed.

Quarts neither know nor cares about any threads spawned by your job, it will simply wait for the job to complete. If your job spawns new threads then exits, then as far as Quartz is concerned, it's finished.

If your job needs to wait for its spawned threads to complete, then you need to use something like an ExecutorService (see javadoc for java.util.concurrent), which will allow the job thread to wait for its spawned threads to complete. If you're using raw java threads, then use Thread.join().

0

精彩评论

暂无评论...
验证码 换一张
取 消