问一个while(true)的问题
public void run(){
do{
fireActionPerformed();
try{
Thread.sleep(delay);
}
catch(InterruptedException interruptedexception){
System.out.println("WARMING: Ticker thread interrupted.");
}
}while(true);
}
这的while(true)循环没有内容,是直接跳过吗?有什么用呢?
[解决办法]
do - while 是不管条件成不成立,都会先走 do 内的代码;
如果while括号内的参数为true,则继续执行,反之则结束循环。
如:
int i = 0;do { i ++; } while (i < 5)当i = 5时,结果为false,结束循环.
[解决办法]