50,504
社区成员
发帖
与我相关
我的任务
分享
import com.sun.corba.se.impl.orb.ParserTable.TestAcceptor1;
public class text {
public static void main(String[] args) {
class ThreadStop extends Thread{
private boolean stoped = false;
@Override
public void run() {
while(!stoped){
try {
System.out.println("11111");
} catch (Exception e) {
e.printStackTrace();
}
}
}
void getStop(){
stoped = true;
}
}
ThreadStop q = new ThreadStop();
q.start();
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
q.getStop();
}
}
while(!stoped){
try {
System.out.println("11111");
} catch (Exception e) {
e.printStackTrace();
}
}
改成
while(!stoped){
try {
//System.out.println("11111");
} catch (Exception e) {
e.printStackTrace();
}
}
然后再试试加与不加volidate的区别,这时候结果就很清楚了(误