Author | Message |
---|---|
se1k1h1mawar1
Posts: 121
|
Posted 09:20 Jun 04, 2016 |
Is this ( this --> for (;;) { ) another way of writing an infinite loop? What is the advantage of using this? It comes from Looper.java of Android sdk (23), line 134: for (;;) { Message msg = queue.next(); // might block if (msg == null) { // No message indicates that the message queue is quitting. return; } |
meishu
Posts: 6
|
Posted 13:21 Jun 04, 2016 |
for (;;) and while(true) are exactly equivalent. However, there is one small, potential advantage to using for (;;) which is that some compilers performing static analysis may complain about the "true" condition in the while loop never evaluating to false, which is not something that gets complained about with for (;;). |
se1k1h1mawar1
Posts: 121
|
Posted 19:54 Jun 04, 2016 |
Wow, that's interesting! Thank you! |