package test1; public class test1 extends Thread { public static void main(String[] args) { // TODO Auto-generated method stub Thread Rabbit = new Thread (new test1 ("rabbit",15,50)); Thread Turtle = new Thread (new test1 ("turtle",12,50)); Turtle.start(); Rabbit.start(); System.out.println("This is the main application."); } String name; int speed; int distance; int curdistance; public test1 (String name,int speed,int distance) { this.name = name; this.speed = speed; this.distance = distance; } public void run() { while(curdistance欢迎分享,转载请注明来源:内存溢出
Java 使用Thread类,模拟龟兔赛跑
使用Thread类,模拟龟兔赛跑
赞
(0)
打赏
微信扫一扫
支付宝扫一扫
IDEA导入web项目显示404无法找到资源或资源不可用
上一篇
2022-12-14
终止线程的优选并不是stop()与destroy()
下一篇
2022-12-14
评论列表(0条)