examthread2.java
来自「JAVA程序设计 丁岳伟 彭敦陆编 高等教育出版社 第7---11章程序」· Java 代码 · 共 30 行
JAVA
30 行
//ExamThread1.java
import java.util.*;
public class ExamThread2 implements Runnable{
String threadName;
public ExamThread2(String threadName){
this.threadName=threadName;
System.out.println(threadName+ "created!");
}
public void run(){
System.out.println(threadName+"started!");
try {
Thread.sleep(1000);
}catch(Exception e){
e.printStackTrace();
}
System.out.println(threadName+" finished!");
}
public static void main(String args[]){
ExamThread2 target1 = new ExamThread2 ("first thread ");
ExamThread2 target2= new ExamThread2 ("second thread ");
ExamThread2 target3= new ExamThread2 ("third thread ");
Thread first,second, third;
first=new Thread(target1);
second=new Thread(target2);
third=new Thread(target3);
first.start( );
second.start( );
third.start( );
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?