首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > JAVA > Eclipse开发 >

问一个while(true)的有关问题

2012-02-03 
问一个while(true)的问题public void run(){do{fireActionPerformed()try{Thread.sleep(delay)}catch(In

问一个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,则继续执行,反之则结束循环。
如:

Java code
int i = 0;do { i ++; } while (i < 5)当i = 5时,结果为false,结束循环.
[解决办法]
探讨
public void run(){
do{
fireActionPerformed();
try{
Thread.sleep(delay);
}
catch(InterruptedException interruptedexception){
System.out.println("WARMING: Ticker thread interrupted.");
}
}while……

热点排行