mirror of
https://github.com/Dichgrem/Java.git
synced 2025-12-18 13:21:59 -05:00
update:demo6
This commit is contained in:
22
com/study/demo6/ThreadDemo2.java
Normal file
22
com/study/demo6/ThreadDemo2.java
Normal 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();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user