mirror of
https://gitee.com/chinabugotech/hutool.git
synced 2025-04-19 03:01:48 +08:00
fix comment
This commit is contained in:
parent
b4c29d2f01
commit
90e77eeff1
@ -25,30 +25,30 @@ import java.util.concurrent.locks.ReentrantLock;
|
||||
|
||||
/**
|
||||
* 任务调度器<br>
|
||||
*
|
||||
*
|
||||
* 调度器启动流程:<br>
|
||||
*
|
||||
*
|
||||
* <pre>
|
||||
* 启动Timer =》 启动TaskLauncher =》 启动TaskExecutor
|
||||
* </pre>
|
||||
*
|
||||
*
|
||||
* 调度器关闭流程:<br>
|
||||
*
|
||||
*
|
||||
* <pre>
|
||||
* 关闭Timer =》 关闭所有运行中的TaskLauncher =》 关闭所有运行中的TaskExecutor
|
||||
* </pre>
|
||||
*
|
||||
*
|
||||
* 其中:
|
||||
*
|
||||
*
|
||||
* <pre>
|
||||
* <strong>TaskLauncher</strong>:定时器每分钟调用一次(如果{@link Scheduler#isMatchSecond()}为<code>true</code>每秒调用一次),
|
||||
* <strong>TaskLauncher</strong>:定时器每分钟调用一次(如果{@link Scheduler#isMatchSecond()}为{@code true}每秒调用一次),
|
||||
* 负责检查<strong>TaskTable</strong>是否有匹配到此时间运行的Task
|
||||
* </pre>
|
||||
*
|
||||
*
|
||||
* <pre>
|
||||
* <strong>TaskExecutor</strong>:TaskLauncher匹配成功后,触发TaskExecutor执行具体的作业,执行完毕销毁
|
||||
* </pre>
|
||||
*
|
||||
*
|
||||
* @author Looly
|
||||
*
|
||||
*/
|
||||
@ -80,7 +80,7 @@ public class Scheduler implements Serializable {
|
||||
// --------------------------------------------------------- Getters and Setters start
|
||||
/**
|
||||
* 设置时区
|
||||
*
|
||||
*
|
||||
* @param timeZone 时区
|
||||
* @return this
|
||||
*/
|
||||
@ -91,7 +91,7 @@ public class Scheduler implements Serializable {
|
||||
|
||||
/**
|
||||
* 获得时区,默认为 {@link TimeZone#getDefault()}
|
||||
*
|
||||
*
|
||||
* @return 时区
|
||||
*/
|
||||
public TimeZone getTimeZone() {
|
||||
@ -101,8 +101,8 @@ public class Scheduler implements Serializable {
|
||||
/**
|
||||
* 设置是否为守护线程<br>
|
||||
* 如果为true,则在调用{@link #stop()}方法后执行的定时任务立即结束,否则等待执行完毕才结束。默认非守护线程
|
||||
*
|
||||
* @param on <code>true</code>为守护线程,否则非守护线程
|
||||
*
|
||||
* @param on {@code true}为守护线程,否则非守护线程
|
||||
* @return this
|
||||
* @throws CronException 定时任务已经启动抛出此异常
|
||||
*/
|
||||
@ -121,7 +121,7 @@ public class Scheduler implements Serializable {
|
||||
|
||||
/**
|
||||
* 是否为守护线程
|
||||
*
|
||||
*
|
||||
* @return 是否为守护线程
|
||||
*/
|
||||
public boolean isDaemon() {
|
||||
@ -130,8 +130,8 @@ public class Scheduler implements Serializable {
|
||||
|
||||
/**
|
||||
* 是否支持秒匹配
|
||||
*
|
||||
* @return <code>true</code>使用,<code>false</code>不使用
|
||||
*
|
||||
* @return {@code true}使用,{@code false}不使用
|
||||
*/
|
||||
public boolean isMatchSecond() {
|
||||
return this.config.isMatchSecond();
|
||||
@ -139,8 +139,8 @@ public class Scheduler implements Serializable {
|
||||
|
||||
/**
|
||||
* 设置是否支持秒匹配,默认不使用
|
||||
*
|
||||
* @param isMatchSecond <code>true</code>支持,<code>false</code>不支持
|
||||
*
|
||||
* @param isMatchSecond {@code true}支持,{@code false}不支持
|
||||
* @return this
|
||||
*/
|
||||
public Scheduler setMatchSecond(boolean isMatchSecond) {
|
||||
@ -150,7 +150,7 @@ public class Scheduler implements Serializable {
|
||||
|
||||
/**
|
||||
* 增加监听器
|
||||
*
|
||||
*
|
||||
* @param listener {@link TaskListener}
|
||||
* @return this
|
||||
*/
|
||||
@ -161,7 +161,7 @@ public class Scheduler implements Serializable {
|
||||
|
||||
/**
|
||||
* 移除监听器
|
||||
*
|
||||
*
|
||||
* @param listener {@link TaskListener}
|
||||
* @return this
|
||||
*/
|
||||
@ -175,7 +175,7 @@ public class Scheduler implements Serializable {
|
||||
/**
|
||||
* 批量加入配置文件中的定时任务<br>
|
||||
* 配置文件格式为: xxx.xxx.xxx.Class.method = * * * * *
|
||||
*
|
||||
*
|
||||
* @param cronSetting 定时任务设置文件
|
||||
* @return this
|
||||
*/
|
||||
@ -204,7 +204,7 @@ public class Scheduler implements Serializable {
|
||||
|
||||
/**
|
||||
* 新增Task,使用随机UUID
|
||||
*
|
||||
*
|
||||
* @param pattern {@link CronPattern}对应的String表达式
|
||||
* @param task {@link Runnable}
|
||||
* @return ID
|
||||
@ -215,7 +215,7 @@ public class Scheduler implements Serializable {
|
||||
|
||||
/**
|
||||
* 新增Task,使用随机UUID
|
||||
*
|
||||
*
|
||||
* @param pattern {@link CronPattern}对应的String表达式
|
||||
* @param task {@link Task}
|
||||
* @return ID
|
||||
@ -228,7 +228,7 @@ public class Scheduler implements Serializable {
|
||||
|
||||
/**
|
||||
* 新增Task,如果任务ID已经存在,抛出异常
|
||||
*
|
||||
*
|
||||
* @param id ID,为每一个Task定义一个ID
|
||||
* @param pattern {@link CronPattern}对应的String表达式
|
||||
* @param task {@link Runnable}
|
||||
@ -240,7 +240,7 @@ public class Scheduler implements Serializable {
|
||||
|
||||
/**
|
||||
* 新增Task,如果任务ID已经存在,抛出异常
|
||||
*
|
||||
*
|
||||
* @param id ID,为每一个Task定义一个ID
|
||||
* @param pattern {@link CronPattern}对应的String表达式
|
||||
* @param task {@link Task}
|
||||
@ -252,7 +252,7 @@ public class Scheduler implements Serializable {
|
||||
|
||||
/**
|
||||
* 新增Task,如果任务ID已经存在,抛出异常
|
||||
*
|
||||
*
|
||||
* @param id ID,为每一个Task定义一个ID
|
||||
* @param pattern {@link CronPattern}
|
||||
* @param task {@link Task}
|
||||
@ -265,7 +265,7 @@ public class Scheduler implements Serializable {
|
||||
|
||||
/**
|
||||
* 移除Task
|
||||
*
|
||||
*
|
||||
* @param id Task的ID
|
||||
* @return this
|
||||
*/
|
||||
@ -276,7 +276,7 @@ public class Scheduler implements Serializable {
|
||||
|
||||
/**
|
||||
* 更新Task执行的时间规则
|
||||
*
|
||||
*
|
||||
* @param id Task的ID
|
||||
* @param pattern {@link CronPattern}
|
||||
* @return this
|
||||
@ -299,7 +299,7 @@ public class Scheduler implements Serializable {
|
||||
|
||||
/**
|
||||
* 获得指定id的{@link CronPattern}
|
||||
*
|
||||
*
|
||||
* @param id ID
|
||||
* @return {@link CronPattern}
|
||||
* @since 3.1.1
|
||||
@ -310,7 +310,7 @@ public class Scheduler implements Serializable {
|
||||
|
||||
/**
|
||||
* 获得指定id的{@link Task}
|
||||
*
|
||||
*
|
||||
* @param id ID
|
||||
* @return {@link Task}
|
||||
* @since 3.1.1
|
||||
@ -321,7 +321,7 @@ public class Scheduler implements Serializable {
|
||||
|
||||
/**
|
||||
* 是否无任务
|
||||
*
|
||||
*
|
||||
* @return true表示无任务
|
||||
* @since 4.0.2
|
||||
*/
|
||||
@ -331,14 +331,14 @@ public class Scheduler implements Serializable {
|
||||
|
||||
/**
|
||||
* 当前任务数
|
||||
*
|
||||
*
|
||||
* @return 当前任务数
|
||||
* @since 4.0.2
|
||||
*/
|
||||
public int size() {
|
||||
return this.taskTable.size();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 清空任务表
|
||||
* @return this
|
||||
@ -359,7 +359,7 @@ public class Scheduler implements Serializable {
|
||||
|
||||
/**
|
||||
* 启动
|
||||
*
|
||||
*
|
||||
* @param isDaemon 是否以守护线程方式启动,如果为true,则在调用{@link #stop()}方法后执行的定时任务立即结束,否则等待执行完毕才结束。
|
||||
* @return this
|
||||
*/
|
||||
@ -370,7 +370,7 @@ public class Scheduler implements Serializable {
|
||||
|
||||
/**
|
||||
* 启动
|
||||
*
|
||||
*
|
||||
* @return this
|
||||
*/
|
||||
public Scheduler start() {
|
||||
@ -380,7 +380,7 @@ public class Scheduler implements Serializable {
|
||||
throw new CronException("Schedule is started!");
|
||||
}
|
||||
|
||||
// 无界线程池,确保每一个需要执行的线程都可以及时运行,同时复用已有现成避免线程重复创建
|
||||
// 无界线程池,确保每一个需要执行的线程都可以及时运行,同时复用已有线程避免线程重复创建
|
||||
this.threadExecutor = ExecutorBuilder.create().useSynchronousQueue().setThreadFactory(//
|
||||
ThreadFactoryBuilder.create().setNamePrefix("hutool-cron-").setDaemon(this.daemon).build()//
|
||||
).build();
|
||||
@ -397,12 +397,12 @@ public class Scheduler implements Serializable {
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 停止定时任务<br>
|
||||
* 此方法调用后会将定时器进程立即结束,如果为守护线程模式,则正在执行的作业也会自动结束,否则作业线程将在执行完成后结束。<br>
|
||||
* 此方法并不会清除任务表中的任务,请调用{@link #clear()} 方法清空任务或者使用{@link #stop(boolean)}方法可选是否清空
|
||||
*
|
||||
*
|
||||
* @return this
|
||||
*/
|
||||
public Scheduler stop() {
|
||||
@ -427,11 +427,11 @@ public class Scheduler implements Serializable {
|
||||
// 停止CronTimer
|
||||
this.timer.stopTimer();
|
||||
this.timer = null;
|
||||
|
||||
|
||||
//停止线程池
|
||||
this.threadExecutor.shutdown();
|
||||
this.threadExecutor = null;
|
||||
|
||||
|
||||
//可选是否清空任务表
|
||||
if(clearTasks) {
|
||||
clear();
|
||||
|
Loading…
x
Reference in New Issue
Block a user