其他分享
首页 > 其他分享> > 简单多线程:龟兔赛跑

简单多线程:龟兔赛跑

作者:互联网

@Test
public void test() {
TR tr = new TR("兔子");
TR tr1 = new TR("乌龟");
tr.start();
tr1.start();
}

class TR extends Thread {
public TR(String name) {
super(name);
}

@Override
public void run() {
for (int i = 1; i < 101; i++) {
System.out.println(getName() + "说,我跑了" + i + "米");
}
}
}

标签:赛跑,TR,龟兔,tr,start,tr1,new,多线程,public
来源: https://www.cnblogs.com/yehuoshun/p/15700915.html