问一个while(true)的问题

yds3300376yd 2011-09-28 06:41:55
public void run(){
do{
fireActionPerformed();
try{
Thread.sleep(delay);
}
catch(InterruptedException interruptedexception){
System.out.println("WARMING: Ticker thread interrupted.");
}
}while(true);
}

这的while(true)循环没有内容,是直接跳过吗?有什么用呢?
...全文
146 12 打赏 收藏 转发到动态 举报
写回复
用AI写文章
12 条回复
切换为时间正序
请发表友善的回复…
发表回复
luyun2011 2011-09-29
  • 打赏
  • 举报
回复
do-while循环,while(true)会使do中的内容一直执行,造成死循环
Colder 2011-09-29
  • 打赏
  • 举报
回复
[Quote=引用 10 楼 fuwenhai 的回复:]
do-while循环,while(true)会使do中的内容一直执行,造成死循环[/Quote]
yds3300376yd 2011-09-29
  • 打赏
  • 举报
回复
多谢各位,懂了懂了~~~
yaming116 2011-09-28
  • 打赏
  • 举报
回复
[Quote=引用楼主 yds3300376yd 的回复:]
public void run(){
do{
fireActionPerformed();
try{
Thread.sleep(delay);
}
catch(InterruptedException interruptedexception){
System.out.println("WARMING: Ticker thread interrupted.");
}
}while……
[/Quote]
要根据你这别的代码,这段代码的功能是让这个现在暂时休眠一段时间,应该是监听端口的
因为并不是需要不停的监听所以暂停一下
剪爱 2011-09-28
  • 打赏
  • 举报
回复
do{执行语句;}while(判断条件);
首先不看判断条件,直接执行一次do里面的语句,然后看判断条件,若始终是真的条件则继续执行do里面的循环的语句,其中判断条件为true,始终为真,则是一个死循环,do里面的循环体始终被执行
xwqfudimo 2011-09-28
  • 打赏
  • 举报
回复
[Quote=引用 6 楼 comaple 的回复:]
这是一个循环啊,执行的是do的内容,while(true)肯定是个死循环。一般用于监听的。
do{
fireActionPerformed();
try{
Thread.sleep(delay);
}
catch(InterruptedException interruptedexception){
System.out.println("WARMING: Ticker thread……
[/Quote]
正解 , 这是个死循环,一般用于监听端口
康派尔 2011-09-28
  • 打赏
  • 举报
回复
这是一个循环啊,执行的是do的内容,while(true)肯定是个死循环。一般用于监听的。
do{
fireActionPerformed();
try{
Thread.sleep(delay);
}
catch(InterruptedException interruptedexception){
System.out.println("WARMING: Ticker thread interrupted.");
}
}
Tobe 2011-09-28
  • 打赏
  • 举报
回复
do - while 是不管条件成不成立,都会先走 do 内的代码;
如果while括号内的参数为true,则继续执行,反之则结束循环。
如:

int i = 0;
do {
i ++;
} while (i < 5)
当i = 5时,结果为false,结束循环.
wangzhiqing3 2011-09-28
  • 打赏
  • 举报
回复
怎么会没有内容
TKD03072010 2011-09-28
  • 打赏
  • 举报
回复
do-while
while 是判断条件
true就是while的内容
LucEaspe 2011-09-28
  • 打赏
  • 举报
回复
执行一次跳出。
亲努力啊 2011-09-28
  • 打赏
  • 举报
回复
这是 do while

58,454

社区成员

发帖
与我相关
我的任务
社区描述
Java Eclipse
社区管理员
  • Eclipse
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧