package Thread.Method;
public class Stop {
public static void main(String[] args) {
DogRunable dogRunable=new DogRunable();
dogRunable.setName("小狗线程");
dogRunable.start();
for (int i = 0; i <30 ; i++) {
System.out.println("主线程跑");
}
}
}
class DogRunable extends Thread{
@Override
public void run() {
for (int i = 0; i <20 ; i++) {
if (i==15){
this.stop();
}
System.out.println(this.getName()+"吃......."+i);
}
}
}
这段代码为什么实现不了多线程 而是主线程跑完再执行的小狗吃线程?