I was looking inside the AtomicInteger
Class and I came across the following method:
/**
* Atomically increments by one the current value.
*
It's the same thing as
while(true) {
//do something
}
...just a little bit less clear.
Notice that the loop will exit if compareAndSet(current, next)
will evaluate as true
.
That is a for ever loop. it is just a loop with no defined conditions to break out.
It's an infinite loop, like while(true)
.
It's just another variation of an infinite loop, just as while(true){}
is.
It is equivalent to while(true)
.
A for-loop has three elements:
for(;;)
is not setting any of them, making it an endless loop.
Reference: The for statement