What should I do if the quartz timing task has not ended and the next one has started?

Quartz scheduled tasks are executed concurrently by default. They will not wait for the last task to be executed. They will be executed as long as the interval expires. This often results in incorrect data being executed.

  • Solution 1:

Set the value of concurrent to false in the Spring configuration file to prohibit concurrent execution.

 <property name="concurrent" value="false" />
  • Solution 2:

You can annotate the class that implements the Job interface

@DisallowConcurrentExecution
public class TestJob implements Job{
    
    
	 @Override
	 public void execute(JobExecutionContext arg0) throws JobExecutionException {
    
    
		  System.out.println("test");
	 }
}

The prohibition of concurrency here means that the same task in the same Job implementation class cannot be concurrent, and other implementation class tasks are not affected.

Guess you like

Origin blog.csdn.net/weixin_49107940/article/details/130298785