增加测试类
This commit is contained in:
9
src/test/java/com/jsh/test/MyRunnable.java
Normal file
9
src/test/java/com/jsh/test/MyRunnable.java
Normal file
@@ -0,0 +1,9 @@
|
||||
package com.jsh.test;
|
||||
|
||||
public class MyRunnable implements Runnable {//实现Runnable接口
|
||||
public void run(){
|
||||
for(int i=0; i<30; i++){
|
||||
System.out.println(Thread.currentThread().getName()+"运行, "+i); //获取当前线程的名称
|
||||
}
|
||||
}
|
||||
}
|
||||
10
src/test/java/com/jsh/test/MyThread.java
Normal file
10
src/test/java/com/jsh/test/MyThread.java
Normal file
@@ -0,0 +1,10 @@
|
||||
package com.jsh.test;
|
||||
|
||||
public class MyThread {
|
||||
public static void main(String[] args) {
|
||||
for (int i = 0; i < 3; i++) {
|
||||
MyRunnable mt = new MyRunnable(); //定义Runnable子类对象
|
||||
new Thread(mt, "第" + i + "个线程").start();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user