Unforgettable experience, and I Xiaohua dating (aka: Three implementations of Java and Detailed timing tasks)

Forget introduced, the school beauty's name is flowers

Since the last flowers with my things in the hotel ( for more details please point me later), she did not talk to me for several days, I do not know what he was born gas, compression may not like to play the boys put it, girls really troublesome, alas!

In order not to make her angry, and I will continue to copy her homework, I went to the river to watch the sunset together about her, and then at night the wind blowing River waterfront stars, the way to ask her to dinner to please her, not to be her boyfriend found her, I specifically spend money to help my friend with her boyfriend out to pack the night, alas Routeng!

We made an appointment at five o'clock in the River Pavilion, three in the afternoon I went to the river bank, he took out a prepared blankets and snacks, sitting in the river waiting for the flowers.

I waited and waited! I waited and waited! Wait until seven o'clock flowers before that, I saw her carrying a large bag over, I am very puzzled and asked her, "You are such a large bag, which is filled with Shaa?"

Flowers: Tent ah!

Baldwin: Why do you carry a tent? ! ? !

Flowers: You do not have a tent, it directly on the ground, that have not been seen doing someone else?

Baldwin: all right! Pasha seen by others, again, you do not stay in the tent will not see the stars begin!

Flowers: the amount of ~ side the stars while playing? That was okay! Sounds pretty exciting, a Baldwin did not think you look silly, could be so bold

Baldwin: This is what's exciting? But you come too late, the sun is gone, I was finished snack

Flowers: Oh really sorry ah! My alarm clock did not go off today, it might be broken

Baldwin: alarm clock that you too do not fly, and now the stars come out not by much, I tell you about Java regular tasks, the next you can write yourself a timer to remind you to do what matter!

First, the relevant

Scene timed task can be very wide, for example, some projects need to check the status of a node on a regular basis; for example, some of the data need to regularly clean up the tasks.

Generally, we achieve in Java regular tasks There are four ways: SpringTask, Quartz, Timer, ScheduledExecutorService, my favorite is SpringTask in the project.

Two, SpringTask

1. Relevant

SpringTask after Spring3.0 introduction, can be seen as lightweight Quartz, use SpringTask is very simple. Spring package can only framework that supports annotations and configuration files in two ways.

2. Notes Act

Related

I used most of the project is annotated method, since the use of annotations, we just need to declare the notes in the configuration file is opened, you can use annotations directly on our regular tasks, but do not have to like the profile method as per times need to modify the configuration file.

Notes method mainly used @Scheduled comments, we first look at the annotation information

Ground floor

@Target({ElementType.METHOD, ElementType.ANNOTATION_TYPE})
@Retention(RetentionPolicy.RUNTIME)
@Documented
@Repeatable(Schedules.class)
public @interface Scheduled {

	String cron() default "";

	String zone() default "";

	long fixedDelay() default -1;

	String fixedDelayString() default "";

	long fixedRate() default -1;

	String fixedRateString() default "";

	long initialDelay() default -1;

	String initialDelayString() default "";

}

The comment has 8 method (version 4.3.11), their roles are:

cron: cron expression specified

zone: corn expression set the time zone, the default is an empty string

fixedDelay: from one task to the next task start time interval (unit: mm)

fixedDelayString: functions as above, just change the return value to String

fixedRate: From a start task to start the next task of the time interval (unit: mm)

fixedDelayString: functions as above, just change the return value to String

initialDelay: Before the first mission to the delay time interval (unit: mm)

initialDelayString: functions as above, just change the return value to String

practice

Profiles enable annotation, your project may include, but are not limited to the following configuration

    <!--开启注解-->
    <mvc:annotation-driven/>

    <context:annotation-config/>
    <!-- 扫描任务所在的包 -->
    <context:component-scan base-package="com.hrms.task"/>

    <!-- 定时任务配置 -->
    <task:annotation-driven scheduler="printTask" mode="proxy"/>
    <task:scheduler id="printTask" pool-size="100"  />

Create a scheduled task, we specify a 2S regular tasks in the following task

import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import java.util.logging.Logger;

/**
 * \* User: Baldwin
 * \* E_Mail: [email protected] || [email protected]
 * \* Date: 2020/3/23
 * \* Time: 15:38
 * \* Description:
 * \
 */
@Component(value = "baldwinTask")
public class BaldwinTask {
    private static final Logger logger = Logger.getLogger("logger");

    @Scheduled(fixedRate = 2000)
    public void printTask(){
        logger.info("My name is Baldwin!!!");
    }
}

 Export

[2020-03-23 04:19:29,557] Artifact SSM_HRMS:war: Artifact is deployed successfully
[2020-03-23 04:19:29,557] Artifact SSM_HRMS:war: Deploy took 5,312 milliseconds
三月 23, 2020 4:19:31 下午 com.hrms.task.BaldwinTask printTask
信息: My name is Baldwin!!!
三月 23, 2020 4:19:33 下午 com.hrms.task.BaldwinTask printTask
信息: My name is Baldwin!!!
三月 23, 2020 4:19:35 下午 com.hrms.task.BaldwinTask printTask
信息: My name is Baldwin!!!
三月 23, 2020 4:19:37 下午 com.hrms.task.BaldwinTask printTask
信息: My name is Baldwin!!!
三月 23, 2020 4:19:39 下午 com.hrms.task.BaldwinTask printTask
信息: My name is Baldwin!!!
三月 23, 2020 4:19:41 下午 com.hrms.task.BaldwinTask printTask
信息: My name is Baldwin!!!
三月 23, 2020 4:19:43 下午 com.hrms.task.BaldwinTask printTask
信息: My name is Baldwin!!!
三月 23, 2020 4:19:45 下午 com.hrms.task.BaldwinTask printTask
信息: My name is Baldwin!!!

3. Profiles law

Configuration file, then we do not have access @Scheduled, and in the [position in the file needs to locate the file directly to schedule tasks

practice

Configuration File

    <context:annotation-config/>

    <!-- 扫描任务所在的包 -->
    <context:component-scan base-package="com.hrms.task"/>

    <!-- 定时任务配置 -->
    <task:scheduled-tasks>
        <!-- 定位到文件,定位到方法,设置三秒钟 -->
        <task:scheduled ref="baldwinTask" method="printTask" fixed-rate="3000"/>
    </task:scheduled-tasks>

Task scheduling file, pay attention to the law in different notes

import org.springframework.stereotype.Component;

import java.util.logging.Logger;

/**
 * \* User: Baldwin
 * \* E_Mail: [email protected] || [email protected]
 * \* Date: 2020/3/23
 * \* Time: 15:38
 * \* Description:
 * \
 */
@Component(value = "baldwinTask")
public class BaldwinTask {

    private static final Logger logger = Logger.getLogger("logger");

    public void printTask(){
        logger.info("My name is Baldwin!!!");
    }
}

Export

[2020-03-23 04:30:37,408] Artifact SSM_HRMS:war: Artifact is deployed successfully
[2020-03-23 04:30:37,409] Artifact SSM_HRMS:war: Deploy took 3,229 milliseconds
三月 23, 2020 4:30:40 下午 com.hrms.task.BaldwinTask printTask
信息: My name is Baldwin!!!
三月 23, 2020 4:30:43 下午 com.hrms.task.BaldwinTask printTask
信息: My name is Baldwin!!!
三月 23, 2020 4:30:46 下午 com.hrms.task.BaldwinTask printTask
信息: My name is Baldwin!!!
三月 23, 2020 4:30:49 下午 com.hrms.task.BaldwinTask printTask
信息: My name is Baldwin!!!

4.SpringTask summary

Because often and spring framework to deal with, so personally I prefer to use SpringTask, but prefer configured once after annotation method, notes law, no longer need to operate the configuration file, add annotations can be used directly in timed tasks, very Convenience.

三, Java Hours

1. Relevant

The timing of scheduled tasks feature in Java is mainly used Timer object, which uses a multi-threaded approach to deal with internally, and multi-threading technology so it still has a very large association. In JDK Timer class in the main function responsible for planning task, which is to start doing something a task at a specified time, but it is the task class encapsulates TimerTask class.

2. TimerTask class by inheriting and implement run () method to be executed from the task definition

Create a scheduled task

import java.util.TimerTask;
import java.util.logging.Logger;

/**
 * \* User: Baldwin
 * \* E_Mail: [email protected] || [email protected]
 * \* Date: 2020/3/23
 * \* Time: 16:40
 * \* Description:
 * \
 */
public class BaldwinTimerTask extends TimerTask {
    private static final Logger logger = Logger.getLogger("logger");
    @Override
    public void run() {
        logger.info("My Name is Baldwin!!!");
    }
}

Start and configure a scheduled task

import java.text.ParseException;
import java.util.Timer;
import java.util.logging.Logger;

/**
 * \* User: Baldwin
 * \* E_Mail: [email protected] || [email protected]
 * \* Date: 2020/3/23
 * \* Time: 16:52
 * \* Description:
 * \
 */
public class TaskStart {
    private static Timer timer=new Timer();
    private static final Logger logger = Logger.getLogger("logger");

    public static void main(String[] args) throws ParseException {
        logger.info("程序启动!!!");
        //设置程序启动后10s才运行
        timer.schedule(new BaldwinTimerTask(), 10000);
    }
}

Export

"C:\Program Files\Java\jdk1.8.0_211\bin\java.exe" "-javaagent:D:\tools\IntelliJ IDEA 2019.1.3\lib\idea_rt.jar=52795:D:\tools\IntelliJ IDEA 2019.1.3\bin" -Dfile.encoding=UTF-8 -classpath "C:\Program Files\Java\jdk1.8.0_211\jre\lib\charsets.jar;C:\Program Files\Java\jdk1.8.0_211\jre\lib\deploy.jar;C:\Program Files\Java\jdk1.8.0_211\jre\lib\ext\access-bridge-64.jar;C:\Program Files\Java\jdk1.8.0_211\jre\lib\ext\cldrdata.jar;C:\Program Files\Java\jdk1.8.0_211\jre\lib\ext\dnsns.jar;C:\Program Files\Java\jdk1.8.0_211\jre\lib\ext\jaccess.jar;C:\Program Files\Java\jdk1.8.0_211\jre\lib\ext\jfxrt.jar;C:\Program Files\Java\jdk1.8.0_211\jre\lib\ext\localedata.jar;C:\Program Files\Java\jdk1.8.0_211\jre\lib\ext\nashorn.jar;C:\Program Files\Java\jdk1.8.0_211\jre\lib\ext\sunec.jar;C:\Program Files\Java\jdk1.8.0_211\jre\lib\ext\sunjce_provider.jar;C:\Program Files\Java\jdk1.8.0_211\jre\lib\ext\sunmscapi.jar;C:\Program Files\Java\jdk1.8.0_211\jre\lib\ext\sunpkcs11.jar;C:\Program Files\Java\jdk1.8.0_211\jre\lib\ext\zipfs.jar;C:\Program Files\Java\jdk1.8.0_211\jre\lib\javaws.jar;C:\Program Files\Java\jdk1.8.0_211\jre\lib\jce.jar;C:\Program Files\Java\jdk1.8.0_211\jre\lib\jfr.jar;C:\Program Files\Java\jdk1.8.0_211\jre\lib\jfxswt.jar;C:\Program Files\Java\jdk1.8.0_211\jre\lib\jsse.jar;C:\Program Files\Java\jdk1.8.0_211\jre\lib\management-agent.jar;C:\Program Files\Java\jdk1.8.0_211\jre\lib\plugin.jar;C:\Program Files\Java\jdk1.8.0_211\jre\lib\resources.jar;C:\Program Files\Java\jdk1.8.0_211\jre\lib\rt.jar;E:\WorkSpaces\IDEAworkspace\SSM_HRMS\target\classes;C:\Users\admin\.m2\repository\org\springframework\spring-core\4.2.9.RELEASE\spring-core-4.2.9.RELEASE.jar;C:\Users\admin\.m2\repository\commons-logging\commons-logging\1.2\commons-logging-1.2.jar;C:\Users\admin\.m2\repository\org\springframework\spring-context\4.2.9.RELEASE\spring-context-4.2.9.RELEASE.jar;C:\Users\admin\.m2\repository\org\springframework\spring-aop\4.2.9.RELEASE\spring-aop-4.2.9.RELEASE.jar;C:\Users\admin\.m2\repository\aopalliance\aopalliance\1.0\aopalliance-1.0.jar;C:\Users\admin\.m2\repository\org\springframework\spring-expression\4.2.9.RELEASE\spring-expression-4.2.9.RELEASE.jar;C:\Users\admin\.m2\repository\org\springframework\spring-beans\4.2.9.RELEASE\spring-beans-4.2.9.RELEASE.jar;C:\Users\admin\.m2\repository\org\springframework\spring-web\4.2.9.RELEASE\spring-web-4.2.9.RELEASE.jar;C:\Users\admin\.m2\repository\org\springframework\spring-jdbc\4.2.9.RELEASE\spring-jdbc-4.2.9.RELEASE.jar;C:\Users\admin\.m2\repository\org\springframework\spring-tx\4.2.9.RELEASE\spring-tx-4.2.9.RELEASE.jar;C:\Users\admin\.m2\repository\org\springframework\spring-webmvc\4.2.9.RELEASE\spring-webmvc-4.2.9.RELEASE.jar;C:\Users\admin\.m2\repository\mysql\mysql-connector-java\3.1.14\mysql-connector-java-3.1.14.jar;C:\Users\admin\.m2\repository\org\mybatis\mybatis\3.4.1\mybatis-3.4.1.jar;C:\Users\admin\.m2\repository\org\mybatis\mybatis-spring\1.3.1\mybatis-spring-1.3.1.jar;C:\Users\admin\.m2\repository\javax\servlet\jstl\1.2\jstl-1.2.jar;C:\Users\admin\.m2\repository\taglibs\standard\1.1.2\standard-1.1.2.jar;C:\Users\admin\.m2\repository\com\fasterxml\jackson\core\jackson-databind\2.8.11\jackson-databind-2.8.11.jar;C:\Users\admin\.m2\repository\com\fasterxml\jackson\core\jackson-annotations\2.8.0\jackson-annotations-2.8.0.jar;C:\Users\admin\.m2\repository\com\fasterxml\jackson\core\jackson-core\2.8.10\jackson-core-2.8.10.jar;C:\Users\admin\.m2\repository\junit\junit\4.12\junit-4.12.jar;C:\Users\admin\.m2\repository\org\hamcrest\hamcrest-core\1.3\hamcrest-core-1.3.jar;C:\Users\admin\.m2\repository\org\springframework\spring-test\4.2.9.RELEASE\spring-test-4.2.9.RELEASE.jar" com.hrms.task.TaskStart
三月 23, 2020 4:56:51 下午 com.hrms.task.TaskStart main
信息: 程序启动!!!
三月 23, 2020 4:57:01 下午 com.hrms.task.BaldwinTimerTask run
信息: My Name is Baldwin!!!

3. Summary

I am not very familiar with Timer, with more than just the simplest example memory write, if you are interested, you can go to their Web search.

Four, Quartz framework

1. Relevant

官网描述:Quartz is a richly featured, open source job scheduling library that can be integrated within virtually any Java application - from the smallest stand-alone application to the largest e-commerce system. Quartz can be used to create simple or complex schedules for executing tens, hundreds, or even tens-of-thousands of jobs; jobs whose tasks are defined as standard Java components that may execute virtually anything you may program them to do. The Quartz Scheduler includes many enterprise-class features, such as support for JTA transactions and clustering.

to sum up:

Quartz 是一个完全由 Java 编写的开源作业调度框架,为在 Java 应用程序中进行作业调度提供了简单却强大的机制。
Quartz 可以与 J2EE 与 J2SE 应用程序相结合也可以单独使用。
Quartz 允许程序开发人员根据时间的间隔来调度作业。
Quartz 实现了作业和触发器的多对多的关系,还能把多个作业与不同的触发器关联。

2. Main Interface

Scheduler - 与调度程序交互的主要API。
Job - 由希望由调度程序执行的组件实现的接口。
JobDetail - 用于定义作业的实例。
Trigger(即触发器) - 定义执行给定作业的计划的组件。
JobBuilder - 用于定义/构建JobDetail实例,用于定义作业的实例。
TriggerBuilder - 用于定义/构建触发器实例。

3. Practice

Quartz framework fully functional, fully realized if the length is too long, there is only a simple example, if necessary, re-opening alone.

Import maven

<dependency>
    <groupId>org.quartz-scheduler</groupId>
    <artifactId>quartz</artifactId>
    <version>2.2.1</version>
</dependency>

<dependency>
    <groupId>org.quartz-scheduler</groupId>
    <artifactId>quartz-jobs</artifactId>
    <version>2.2.1</version>
</dependency>

Create a scheduled task

import org.quartz.*;

import java.util.logging.Logger;

/**
 * \* User: Baldwin
 * \* E_Mail: [email protected] || [email protected]
 * \* Date: 2020/3/23
 * \* Time: 17:25
 * \* Description:
 * \
 */
public class BaldwinQuartzTask implements Job {
    private static final Logger logger = Logger.getLogger("logger");
    @Override
    public void execute(JobExecutionContext jobExecutionContext) throws JobExecutionException {
        JobDetail jobDetail = jobExecutionContext.getJobDetail();
        //等待传入的值
        String age = jobDetail.getJobDataMap().getString("age");
        logger.info("My name is Baldwin,my age is "+age);
    }
}

Timer entrance

import org.quartz.*;
import org.quartz.impl.StdSchedulerFactory;

import java.text.ParseException;
import java.util.Timer;
import java.util.logging.Logger;

/**
 * \* User: Baldwin
 * \* E_Mail: [email protected] || [email protected]
 * \* Date: 2020/3/23
 * \* Time: 16:52
 * \* Description:
 * \
 */
public class TaskStart {
    private static Timer timer=new Timer();
    private static final Logger logger = Logger.getLogger("logger");

    public static void main(String[] args) throws ParseException {
        logger.info("程序启动!!!");
        JobDetail jobDetail = JobBuilder.newJob(BaldwinQuartzTask.class)
                //传值
                .usingJobData("age","18")
                .withIdentity("job","task")
                .build();
        //定义一个Trigger
        Trigger trigger = TriggerBuilder.newTrigger().withIdentity("trigger", "task")
                //加入 scheduler之后立刻执行
                .startNow()
                //定时 ,每个3秒钟执行一次
                .withSchedule(SimpleScheduleBuilder.simpleSchedule().withIntervalInSeconds(3)
                        //重复执行
                        .repeatForever())
                .build();


        try {
            //创建scheduler
            Scheduler scheduler = StdSchedulerFactory.getDefaultScheduler();
            scheduler.scheduleJob(jobDetail, trigger);
            scheduler.start(); //运行一段时间后关闭
            try {
                Thread.sleep(10000);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
            scheduler.shutdown();
        } catch (
                SchedulerException e) {
            e.printStackTrace();
        }

    }
}

operation result

"C:\Program Files\Java\jdk1.8.0_211\bin\java.exe" "-javaagent:D:\tools\IntelliJ IDEA 2019.1.3\lib\idea_rt.jar=54203:D:\tools\IntelliJ IDEA 2019.1.3\bin" -Dfile.encoding=UTF-8 -classpath "C:\Program Files\Java\jdk1.8.0_211\jre\lib\charsets.jar;C:\Program Files\Java\jdk1.8.0_211\jre\lib\deploy.jar;C:\Program Files\Java\jdk1.8.0_211\jre\lib\ext\access-bridge-64.jar;C:\Program Files\Java\jdk1.8.0_211\jre\lib\ext\cldrdata.jar;C:\Program Files\Java\jdk1.8.0_211\jre\lib\ext\dnsns.jar;C:\Program Files\Java\jdk1.8.0_211\jre\lib\ext\jaccess.jar;C:\Program Files\Java\jdk1.8.0_211\jre\lib\ext\jfxrt.jar;C:\Program Files\Java\jdk1.8.0_211\jre\lib\ext\localedata.jar;C:\Program Files\Java\jdk1.8.0_211\jre\lib\ext\nashorn.jar;C:\Program Files\Java\jdk1.8.0_211\jre\lib\ext\sunec.jar;C:\Program Files\Java\jdk1.8.0_211\jre\lib\ext\sunjce_provider.jar;C:\Program Files\Java\jdk1.8.0_211\jre\lib\ext\sunmscapi.jar;C:\Program Files\Java\jdk1.8.0_211\jre\lib\ext\sunpkcs11.jar;C:\Program Files\Java\jdk1.8.0_211\jre\lib\ext\zipfs.jar;C:\Program Files\Java\jdk1.8.0_211\jre\lib\javaws.jar;C:\Program Files\Java\jdk1.8.0_211\jre\lib\jce.jar;C:\Program Files\Java\jdk1.8.0_211\jre\lib\jfr.jar;C:\Program Files\Java\jdk1.8.0_211\jre\lib\jfxswt.jar;C:\Program Files\Java\jdk1.8.0_211\jre\lib\jsse.jar;C:\Program Files\Java\jdk1.8.0_211\jre\lib\management-agent.jar;C:\Program Files\Java\jdk1.8.0_211\jre\lib\plugin.jar;C:\Program Files\Java\jdk1.8.0_211\jre\lib\resources.jar;C:\Program Files\Java\jdk1.8.0_211\jre\lib\rt.jar;E:\WorkSpaces\IDEAworkspace\SSM_HRMS\target\classes;C:\Users\admin\.m2\repository\org\springframework\spring-core\4.2.9.RELEASE\spring-core-4.2.9.RELEASE.jar;C:\Users\admin\.m2\repository\commons-logging\commons-logging\1.2\commons-logging-1.2.jar;C:\Users\admin\.m2\repository\org\springframework\spring-context\4.2.9.RELEASE\spring-context-4.2.9.RELEASE.jar;C:\Users\admin\.m2\repository\org\springframework\spring-aop\4.2.9.RELEASE\spring-aop-4.2.9.RELEASE.jar;C:\Users\admin\.m2\repository\aopalliance\aopalliance\1.0\aopalliance-1.0.jar;C:\Users\admin\.m2\repository\org\springframework\spring-expression\4.2.9.RELEASE\spring-expression-4.2.9.RELEASE.jar;C:\Users\admin\.m2\repository\org\springframework\spring-beans\4.2.9.RELEASE\spring-beans-4.2.9.RELEASE.jar;C:\Users\admin\.m2\repository\org\springframework\spring-web\4.2.9.RELEASE\spring-web-4.2.9.RELEASE.jar;C:\Users\admin\.m2\repository\org\springframework\spring-jdbc\4.2.9.RELEASE\spring-jdbc-4.2.9.RELEASE.jar;C:\Users\admin\.m2\repository\org\springframework\spring-tx\4.2.9.RELEASE\spring-tx-4.2.9.RELEASE.jar;C:\Users\admin\.m2\repository\org\springframework\spring-webmvc\4.2.9.RELEASE\spring-webmvc-4.2.9.RELEASE.jar;C:\Users\admin\.m2\repository\mysql\mysql-connector-java\3.1.14\mysql-connector-java-3.1.14.jar;C:\Users\admin\.m2\repository\org\mybatis\mybatis\3.4.1\mybatis-3.4.1.jar;C:\Users\admin\.m2\repository\org\mybatis\mybatis-spring\1.3.1\mybatis-spring-1.3.1.jar;C:\Users\admin\.m2\repository\javax\servlet\jstl\1.2\jstl-1.2.jar;C:\Users\admin\.m2\repository\taglibs\standard\1.1.2\standard-1.1.2.jar;C:\Users\admin\.m2\repository\com\fasterxml\jackson\core\jackson-databind\2.8.11\jackson-databind-2.8.11.jar;C:\Users\admin\.m2\repository\com\fasterxml\jackson\core\jackson-annotations\2.8.0\jackson-annotations-2.8.0.jar;C:\Users\admin\.m2\repository\com\fasterxml\jackson\core\jackson-core\2.8.10\jackson-core-2.8.10.jar;C:\Users\admin\.m2\repository\junit\junit\4.12\junit-4.12.jar;C:\Users\admin\.m2\repository\org\hamcrest\hamcrest-core\1.3\hamcrest-core-1.3.jar;C:\Users\admin\.m2\repository\org\springframework\spring-test\4.2.9.RELEASE\spring-test-4.2.9.RELEASE.jar;C:\Users\admin\.m2\repository\org\quartz-scheduler\quartz\2.2.1\quartz-2.2.1.jar;C:\Users\admin\.m2\repository\c3p0\c3p0\0.9.1.1\c3p0-0.9.1.1.jar;C:\Users\admin\.m2\repository\org\slf4j\slf4j-api\1.6.6\slf4j-api-1.6.6.jar;C:\Users\admin\.m2\repository\org\quartz-scheduler\quartz-jobs\2.2.1\quartz-jobs-2.2.1.jar" com.hrms.task.TaskStart
三月 23, 2020 5:42:40 下午 com.hrms.task.TaskStart main
信息: 程序启动!!!
SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.
三月 23, 2020 5:42:40 下午 com.hrms.task.BaldwinQuartzTask execute
信息: My name is Baldwin,my age is 18
三月 23, 2020 5:42:43 下午 com.hrms.task.BaldwinQuartzTask execute
信息: My name is Baldwin,my age is 18
三月 23, 2020 5:42:46 下午 com.hrms.task.BaldwinQuartzTask execute
信息: My name is Baldwin,my age is 18
三月 23, 2020 5:42:49 下午 com.hrms.task.BaldwinQuartzTask execute
信息: My name is Baldwin,my age is 18

4.Quartz summary

Quartz three elements:

  • Scheduler: Task Scheduler, tasks are all from here.
  • Trigger: trigger, define the task execution interval.
  • JobDetail & Job: logical definition of specific tasks to perform.

Quartz framework is complex, can not be described in detail in an article, so stay tuned for more content

V. Summary

1. I am in the habit of projects with SpringTask currently looking at Quartz content, but the content is not very familiar with the Timer temporarily

2.SpringTask be lightweight Quartz, if the project do not ask, you can use SpringTask

3.Quartz is a pure java open source development framework for java programmers in terms of origin, whether or api documentation relative or very friendly, but also very easy to use. In fact, several of the interface is the most important quartz scheduler ·, job, jobdetai, Trigger, jobBuilder. The most important thing Trigger, then deep point, the most important thing cron expression.

FOLLOW

Flowers holding head fighting back sleep listening to Baldwin's explanation, until 11 o'clock finally be listening, so can not wait to say to Baldwin "WDNMD, finally finished, the finished thing quickly get down to business now! I tell you that I today wear underwear can be good-looking. "

Baldwin: Oh wc, all eleven, I've got to go find your boyfriend tonight about his night with the bag, do not worry that his past

Flowers:? ? ? WDNMD, CSB

Baldwin: a slip of the slip, and you remember it tidy trash ah, I first went

Published 51 original articles · won praise 177 · views 130 000 +

Guess you like

Origin blog.csdn.net/shouchenchuan5253/article/details/105043628