mirror of
https://github.com/Dichgrem/Java.git
synced 2025-12-18 13:21:59 -05:00
update:demo6
This commit is contained in:
20
com/study/demo6/ThreadDemo1.java
Normal file
20
com/study/demo6/ThreadDemo1.java
Normal file
@@ -0,0 +1,20 @@
|
||||
package com.study.demo6;
|
||||
|
||||
public class ThreadDemo1 {
|
||||
static class MyThread extends Thread {
|
||||
@Override
|
||||
public void run() {
|
||||
for (int i = 1; i <= 5; i++) {
|
||||
System.out.println("当前线程:" + getName() + ",输出次数 " + i);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
MyThread s1 = new MyThread();
|
||||
MyThread s2 = new MyThread();
|
||||
|
||||
s1.start();
|
||||
s2.start();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user