Scheduled tasks in spring

     Since Spring 3.1, scheduled tasks have become very simple in spring. You can use @EnableScheduling on the configuration class or the class of the method to be executed to enable support for scheduled tasks, and then use the annotation @Scheduled on the method to execute the scheduled task to declare that this is a scheduled task.

      There are various attributes in the @Scheduled annotation, fixedRate means to execute every fixed time, @Scheduled (fixedRate=5000) means to execute every 5 seconds.

        corn means to execute according to the specified time, @Scheduled(corn="0 30 23 ? * *"), means to execute at 11:30 every night, the first digit represents the second (0~59), and the second digit represents the minute (0~ 59), the third digit represents the hour (0~23), the fourth digit represents the day (0~30), the fifth digit represents the month (0~11), and the sixth digit represents the week (1~7, 7=sun), the 7th digit represents the year (1970~2099), each digit is separated by a space, (1-8) represents a period of time, (1-8/2) represents every 2 in this interval class Hour, (1,2,3) represents a time list, because the number of days in the time and the number of days in the month will conflict, so one will be represented by a question mark, * represents a wildcard, including all eligible cases.

    fixedDelay, indicates how long to delay execution after execution @Scheduled(fixedDelay="5000"), indicates execution after 5 seconds of delay.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324482421&siteId=291194637