思路
- 跑道,设置长度,设置标志位是否跑完
- 如果跑完,标志位反转,输出语句,结束run方法
run方法
public void run() {
while (!isOver){
for (int i = trackLength;i>=0; i--) {
if(i == 0){
this.isOver=true;
System.out.println("Winner is "+Thread.currentThread().getName());
}
}
}
}
main方法
public static void main(String[] args) {
Track track = new<