现在的位置: 首页 > 综合 > 正文

thread

2014年03月21日 ⁄ 综合 ⁄ 共 673字 ⁄ 字号 评论关闭

import java.util.*;
public class thread1  {

/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub

thread1 t=new thread1();
mm m=new mm();
m.start();
jj j=new jj();
Thread t1=new Thread(j);
t1.start();
t1.stop();

}
public thread1() {
// TODO Auto-generated constructor stub
   System.out.print("hello\n");
}

}
class mm extends Thread{
public void run(){
int i=0;
while(true)
{
try {
Thread.sleep(100);
} catch (Exception e) {
// TODO: handle exception
}

System.out.print(i+"hello\n");
i++;
if(i==8)
break;
}
}
}
class jj implements Runnable{
int i=0;
public void run(){
while(true)
{
try{Thread.sleep(100);
}catch (Exception e) {
e.printStackTrace();
// TODO: handle exception
}

System.out.print("nihao+"+i+"\n");
i++

;
if(i==9)
break;

}
}
}

【上篇】
【下篇】

抱歉!评论已关闭.