增加测试类

This commit is contained in:
季圣华
2018-09-09 23:31:47 +08:00
parent 12060b7ef2
commit a52383534f
2 changed files with 19 additions and 0 deletions

View 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); //获取当前线程的名称
}
}
}

View 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();
}
}
}