update:demo6

This commit is contained in:
dichgrem
2025-12-14 13:30:08 +08:00
parent 43c6b58317
commit 9285e13f89
3 changed files with 94 additions and 0 deletions

View File

@@ -0,0 +1,22 @@
package com.study.demo6;
public class ThreadDemo2 {
static class CountTask implements Runnable {
@Override
public void run() {
for (int i = 1; i <= 10; i++) {
System.out.println(Thread.currentThread().getName() + " 计数:" + i);
try {
Thread.sleep(500);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
}
}
public static void main(String[] args) {
Thread t = new Thread(new CountTask(), "计数线程");
t.start();
}
}