The Java – quartz job vs. thread executes a task immediately
Assuming I have some units of work to complete, I want to execute asynchronously relative to the rest of my application, because it may take a long time, such as 10 seconds to 2 minutes To do this, I am considering two options:
>Set the quartz job with a simple trigger, which can only be triggered once and triggered as soon as possible. > Create an instance of Runnable, give it to Thread, and then call run ();.
In the above, I have the following questions:
>What do you get with quartz jobs that threads don't have? > What's not the use of runnable things to let me use quartz jobs? > In terms of best practices, what criteria should be used to determine the quartz jobs and runnables for this use case?
Solution
With quartz, you can "well implement" many functions, such as:
>Transaction management of job execution > work persistence so that we can understand the status of running work > cluster support > scheduling control, even if you only need a simple trigger But it offers possibilities
Without using it, you have to control them yourself. Some problems may be complex
Start a new thread:
>Light weight, no job persistence, quartz API, etc. > your application runs without additional dependencies (quartz) > error sources (from quartz) are reduced
It depends on what kind of work you want to start and whether other functions of your application also require job scheduling
If your concern is only asynchronous, you can start a thread If there are other problems, such as clustering, you can consider using quartz