Back to Intellij Community

InfiniteLoopStatement

java/java-impl/resources/inspectionDescriptions/InfiniteLoopStatement.html

2025.3-rc-2430 B
Original Source

Reports for, while, or do statements that can only exit by throwing an exception. While such statements may be correct, they often happen due to coding errors.

Example:

for (;;) {
  }

Use the Ignore when placed in Thread.run option to ignore the infinite loop statements inside Thread.run. It may be useful for the daemon threads.

Example:

new Thread(() -> {
    while (true) {
    }
  }).start();