多线程下的if,经常是while(...)
对于死等,在jdk中很多使用了 for(;;)
狗了一下 while(true) vs for(;;),有种说法是汇编级别,for(;;)更节省。
当然,该结论没代码,没版本,没验证方法,暂报疑惑。且22世纪了,代码可以傻些。
while (true) { //(1)
//for (;;) { //(2)
//for (int i = 1; i > 0; i++) //(3)
if (args.length == 1) break;
if (args.length == 2) break;
}
sun jdk 6 ,默认编译。
使用 Java Bytecode Editor和 JD 看了一下 *.class
能看到 (1)和(2) 被编译器弄成一样了。
等效于:
while ((args.length != 1) && (args.length != 2));
(3)等效于
for (int i = 1; i > 0; i++)
if ((args.length == 1) || (args.length == 2)) break;
基本结论,
1. 个人习惯,爱用哪个用哪个,编译器都会私下做些事。
2. for (int i = 1; i > 0; i++) 不是死等,上限是正数最大值。
所以对于不太确定是否死掉的死等,这个算是活等。
分享到:
相关推荐
ture. We offer this design-centric approach because, as we talked to several companies about their programs, we discovered one of the keys to their success was the willing‐ ness to not stick to a ...
abstract as base bool break byte case catch char checked class const continue decimal default delegate do double else enum event explicit extern false finally fixed float for foreach goto if implicit ...
ture of most human pursuits, and the idea that people clas- sify together those things that people ¯nd similar is both intuitive and popular across a wide range of disciplines. Es- timation of di®...
1Complete a recursive–descent parser for TINY+. Parser gives syntax analysis to the tokens generated by the scanner. Output of the parser is an abstract syntax tree. 2Semantic analyzer builds the ...
实现python 中的break 功能 countinue for loop 实现 python 中的 countinue 功能 countine for loop if exit for loop if 4.evalute python 中直接调⽤eval() 的关键字 有 runkeyworks should be ture evalute ${...
关键字:int char if else real for do while 数字、变量名(不使用下划线,头字母不为数字)、符号 词法分析生成*.TAKEN、*.SymbolTable两个文件。 保留部分语法分析接口,可以继续完成。 词法分析部分在Lex文件夹...
ed question and the user profile, while ignoring the important statistical features, including the question-specific statistical fea-ture and the user-specific statistical features. Moreover, ...
然后用while和do…while语句完成同样的循环。 解: for循环: for (int n = 100; n ; n += 2); while循环: int x = 100; while (n ) n += 2; do…while循环: int n = 100; do { n += 2; } while(n ); 2-14 if...
WHILE i<n BEGIN FOR j:=1 TO n DO x:=x+1;i:=i*2 END; 13. 下面程序段中带有下划线的语句的执行次数的数量级是( ) 【合肥工业大学 2001 三、1(2分)】 i:=n*n WHILE i<>1 DO i:=i div 2; 14. 计算机执行下面的...
The interface gives standard access to as many features as possible, while leaving room for future ex¬ten-sions and vendor-specific customizations. Applications should be able to get the tablet ...