62,623
社区成员
发帖
与我相关
我的任务
分享public class test {
/**
* @param args
*/
public static void main(String[] args) {
Thread1 t1=new Thread1();
Thread t2=new Thread(new Thread2());
t1.start();
t2.start();
}
}
class Thread1 extends Thread{
public void run(){
while(true){
try{
System.out.println("Thread1 is runing");
this.currentThread().sleep(1000);
}catch(Exception e){
System.out.println(e);
}
}
}
}
class Thread2 implements Runnable {
public void run(){
while(true){
try{
System.out.println("Thread2 is runing");
Thread.currentThread().sleep(1000);
}catch(Exception e){
System.out.println(e);
}
}
}
}