Small class D - Basics zero SpringBoot2.X to combat _ Section 10 SpringBoot integration tasks and the timing of asynchronous task processing _41, SpringBoot explain the timing of the task schedule

notes

1, SpringBoot explain the timing of the task schedule
    Introduction: What is timed task to explain the difference between regular and common tasks

        1, regular tasks common Java class that comes java.util.Timer
            timer: Configuration is too much trouble, time delay problem
            timertask: not recommended

        2, Quartz framework
            simpler configuration
            xml annotation or

        3, SpringBoot manner using annotations opening timing task
            1) start the class which @EnableScheduling opening timing of the task, auto scan
            2) traffic class annotated timer task is to scan the container @Component
            3) a method of adding the timing of execution Notes on @Scheduled (fixedRate = 2000) performed regularly once

Start





Start classes annotate

new task package, the following new class TestTask






every two seconds for the current time output



 

Guess you like

Origin www.cnblogs.com/wangjunwei/p/11426757.html