我正在查看AtomicInteger类内部,我遇到了以下方法:
/**
* Atomically increments by one the current value.
*
* @return the previous value
*/
public final int getAndIncrement() {
for (;;) {
int current = get();
int next = current + 1;
if (compareAndSet(current, next))
return current;
}
}
Run Code Online (Sandbox Code Playgroud)
有人解释是什么for(;;)意思吗?
例如:
void thisIsAnExample(Hello* bye, char* name, int num, in* arr, int* sum){
GoodBye x;;
x.funName = name;
.
.
.
Run Code Online (Sandbox Code Playgroud) Moin,我刚刚在一些源代码中找到了for循环.
for (;;) {
// some work
if (condition) {
break;
}
}
Run Code Online (Sandbox Code Playgroud)
这是怎么回事 for (;;) ?