Posted on 2008-02-06 02:11
Java蜘蛛人 --郑成桥 阅读(270)
评论(0) 编辑 收藏
public class Test extends Thread {
private String tran;
public Test(String tran)
{
this.tran=tran;
}
@Override
public void run() {
try {
if(tran.equals("tran"))
show();
else
show1();
} catch (Exception e) {
e.printStackTrace();
// TODO: handle exception
}
}
public void show()throws Exception
{
for(int i=100;i>0;i--)
{
System.out.println("show "+i);
if(i==50)
Thread.sleep(200);
}
}
public void show1()throws Exception
{
for(int i=100;i>0;i--)
{
System.out.println("show1 "+i);
if(i==50)
Thread.sleep(200);
}
}
public static void main(String[] args) {
Thread show=new Test("tran");
Thread show1=new Test("tran2");
show.start();
show1.start();
}
}