add more demo for creating new thred

This commit is contained in:
2025-02-17 13:36:08 +08:00
parent f5472740be
commit cc0ecc57bb
6 changed files with 119 additions and 0 deletions

View File

@@ -0,0 +1,18 @@
package createthread;
import java.util.Timer;
import java.util.TimerTask;
public class CreateByTimer {
public static void main(String[] args) {
Timer timer = new Timer();
timer.schedule(new TimerTask() {
@Override
public void run() {
System.out.println("create thread by using timer");
}
}, 0, 1000);
}
}