The term "infinite loop" refers to any execution instance of a loop in which the loop's exit criteria are never satisfied; such a loop would perform a potentially infinite number of iterations of the loop body. The general problem of determining whether the execution of a loop with given ...

learn more… | top users | synonyms

39
votes
18answers
7k views

Is “for(;;)” faster than “while (TRUE)”? If not, why do people use it?

for (;;) { //Something to be done repeatedly } I have seen this sort of thing used a lot, but I think it is rather strange... Wouldn't it be much clearer to say while(true), or something along ...
33
votes
23answers
15k views

for ( ; ; ) or while ( true ) - Which is the Correct C# Infinite Loop?

Back in my C/C++ days, coding an "infinite loop" as while ( true ) felt more natural and seemed more obvious to me as opposed to for ( ; ; ) An encounter with PC-lint in the late 1980's and ...
25
votes
8answers
2k views

Endless for loop

I have the following loop: for (byte i = 0 ; i < 128; i++) { System.out.println(i + 1 + " " + name); } When I execute my programm it prints all numbers from -128 to 127 in an infinite loop. ...
22
votes
4answers
34k views

How to create an infinite loop in Windows batch file?

This is basically what I want in a batch file. I want to be able to re-run "Do Stuff" whenever I press any key to go past the "Pause". while(true){ Do Stuff Pause } Looks like there are ...
20
votes
2answers
676 views

how to declare i and j to make it be an infinite loop?

while( i <= j && i >= j && i != j) {} how to declare i and j to make it be an infinite loop ? // it's an interview question I met. it's asking what's the declarations of i ...
18
votes
1answer
2k views

Infinite 100% CPU usage at java.io.FileInputStream.readBytes(Native Method)

I'm right now debugging a program which has two threads per one external process, and those two threads keep on reading Process.getErrorStream() and Process.getInputStream() using a while ((i = ...
16
votes
4answers
516 views

Why this for-loop never ends

I'm doing some research about Java and find this very confusing: for (int i = 0; i < 10; i = i++) { System.err.print("hoo... "); } This is never ending loop! Anybody has good explanation why ...
16
votes
5answers
729 views

How to handle an “infinite” IEnumerable?

A trivial example of an "infinite" IEnumerable would be IEnumerable<int> Numbers() { int i=0; while(true) { yield return unchecked(i++); } } I know, that foreach(int i in ...
14
votes
2answers
724 views

curious about how “loop = loop” is evaluated in Haskell

I thought expressions like this would cause Haskell to evaluate forever. But the behaviors in both GHCi and the compiled program surprised me. For example, in GHCi, these expressions blocked until I ...
14
votes
6answers
655 views

C++ - Can massive nested loops cause the linker to run endlessly when compiling in Release-Mode?

I'm compiling a very small Win32 command-line application in VS2010 Release-Mode, with all speed optimizations turned on (not memory optimizations). This application is designed to serve a single ...
12
votes
7answers
3k views

Detecting infinite loop in brainfuck program

I have written a simple brainfuck interpreter in MATLAB script language. It is fed random bf programs to execute (as part of a genetic algorithm project). The problem I face is, the program turns out ...
12
votes
2answers
2k views

C# - How to create a non-detectable infinite loop?

This is just an "I am Curious" question. In C#-in-depth Jon Skeet says about lambda expressions: "if there is a nonvoid return type every code path has to return a compatible value." (Page 233) The ...
11
votes
5answers
3k views

AMD64 — nopw assembly instruction?

I made the following (insane) code in C: long i = 0; main() { recurse(); } recurse() { i++; recurse(); } When compiled with gcc -O2, the compiler recognizes the infinite recursion and ...
10
votes
3answers
975 views

NodeJS memory consumption in an infinite loop

I don't know if this is a bug with Node or V8, but if I run the following code the node process leaks memory. The GC never seems to kick in and in a few seconds it's consuming >1GB of memory. This is ...
10
votes
5answers
426 views

When running user inputed Javascript, is there a way to detect and stop “problem” scripts?

On a page, something like jsFiddle, that executes user inputed Javascript, is there a way to stop / disrupt "problem" scripts running in an iframe? The major class of problem scripts would be ...

1 2 3 4 5 49
15 30 50 per page