Questions tagged [infinite-loop]

An "infinite loop" is a loop in which the 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 preconditions will result in an infinite loop is undecidable; in other words, there is no algorithm to determine whether an execution of a loop will eventually terminate. This is known as the halting problem.

3528 questions
7
votes
5 answers

How to have a FileSystemWatcher thread run forever?

I need to have a FileSystemWatcher run in an infinite loop to monitor a file for changes, but this file will only change every few days, and maybe only once a week. In the MSDN sample of a FileSystemWatcher, there is a loop while the user doesn't…
Tai Squared
  • 12,273
  • 24
  • 72
  • 82
7
votes
4 answers

PHP connection_aborted() not working correctly

I have the following code: ignore_user_abort(true); while(!connection_aborted()) { // do stuff } and according to the PHP documentation, this should run until the connection is closed, but for some reason, it doesn't, instead it keeps running…
kevmo314
  • 4,223
  • 4
  • 32
  • 43
7
votes
6 answers

Infinite loop in SQL?

There is some way to implement a infinite loop in SQL?? I was thinking on some like a select inside another one, recursively... (Maybe im talking foolishness)
Diogo
  • 1,527
  • 7
  • 19
  • 29
7
votes
3 answers

How to find an infinite loop in a java web application?

One day our java web application goes up to 100% CPU usage. A restart solve the incident but not the problem because a few hours after the problem came back. We suspected a infinite loop introduced by a new version but we didn't make any change on…
Franck
  • 944
  • 14
  • 28
7
votes
5 answers

Why is it so bad to run a PHP script continuously?

I have a map. On this map I want to show live data collected from several tables, some of which have astounding amounts of rows. Needless to say, fetching this information takes a long time. Also, pinging is involved. Depending on servers being…
Hubro
  • 56,214
  • 69
  • 228
  • 381
7
votes
1 answer

Maximum update depth exceeded. This can happen when a component repeatedly calls setState inside componentWillUpdate or componentDidUpdate

I'm making this Conway's game of life react project and it was working just fine but when I added the last couple of buttons to clear the board and some other functionalities react gave me this error Maximum update depth exceeded. This can happen…
UWGOOSE
  • 833
  • 3
  • 11
  • 20
7
votes
1 answer

strange string.IndexOf behavour

I wrote the following snippet to get rid of excessive spaces in slabs of text int index = text.IndexOf(" "); while (index > 0) { text = text.Replace(" ", " "); index = text.IndexOf(" "); } Generally this works fine, albeit rather…
Andrew Harry
  • 13,773
  • 18
  • 67
  • 102
7
votes
4 answers

Infinite loop scrolling using UIScrollView in Swift

I am trying to make an infinite loop image gallery app. I did it by setting up a UIScrollView inside which I inserted UIImageViews. I am able to load 4 images and swipe between them, but the problem I have is how to implement the infinite scroll,…
Igor Ani
  • 231
  • 1
  • 3
  • 13
7
votes
2 answers

How do I "Pause" a console application when the user presses escape?

I am creating a C# console application that will be performing an infinite process. How can I get the application to "pause" when the user presses the escape key? Once the user presses the escape key I want the option to either exit the application…
Hooplator15
  • 1,540
  • 7
  • 31
  • 58
7
votes
1 answer

How to run a Haskell program endlessly using only Haskell?

I have small program that need to be executed every 5 minutes. For now, I have shell script that perform that task, but I want to provide for user ability to run it without additional scripts via key in CLI. What is the best way to achieve this?
7
votes
5 answers

Infinite loop detection

I wonder if it is possible to detect and/or stop infinite loop with basic java knowledge. I got a school task(which considers our programming knowledge is on basic level) where we should take an input (int) from user and then take the sum of squares…
SadCoffeeBean
  • 303
  • 2
  • 5
  • 13
7
votes
5 answers

(Java) exiting a loop "remotely"

I have a piece of Java program that essentially does the following: public static void main(String[] args) { while(true) { // does stuff ... } } The infinite loop is there by design - when left alone the program will loop infinitely. For…
illu
  • 79
  • 2
7
votes
7 answers

Whats wrong with this while loop?

boolean r = false ; int s = 0 ; while (r == false) ; { s = getInt() ; if (!(s>=0 && s<=2)) System.out.println ("try again not a valid response") ; else r = true ; } The text never displays itself even when a 3 or a 123 is entered…
David
  • 14,569
  • 34
  • 78
  • 107
7
votes
2 answers

Infinite Loop of layoutAttributesForElementsInRect

I have absolutely zero idea why this is happening, but for whatever reason a collection view I am using is infinitely looping the [UICollectionViewData layoutAttributesForElementsInRect:] method. The collection view is inside of my custom navigation…
Infinity James
  • 4,667
  • 5
  • 23
  • 36
7
votes
5 answers

Why does the C# compiler not even warn about endless recursion?

A legacy app is in an endless loop at startup; I don't know why/how yet (code obfuscation contest candidate), but regarding the method that's being called over and over (which is called from several other methods), I thought, "I wonder if one of the…
B. Clay Shannon-B. Crow Raven
  • 8,547
  • 144
  • 472
  • 862