You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
test/src/main/java/com/thread/MyThreadMethod.java

20 lines
718 B

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

package com.thread;
/**
* 线程执行方法(做一些项目启动后 一直要执行的操作比如根据时间自动更改订单状态比如订单签收30天自动收货功能比如根据时间来更改状态
*/
public class MyThreadMethod extends Thread {
public void run() {
while (!this.isInterrupted()) {// 线程未中断执行循环
try {
Thread.sleep(5000); //每隔2000ms执行一次
} catch (InterruptedException e) {
e.printStackTrace();
}
// ------------------ 开始执行 ---------------------------
// System.out.println("线程执行中:" + System.currentTimeMillis());
}
}
}