-1

I have some kind of automation app that is calling functions from another app (lets call it host). However, it is doing it so fast, that host gets crash. Is there any way to slow down whole app or function? Weird point is that on debug it works perfectly, when I go step-by-step, but host crash just when I press continue.

  • Provide code examples. – Leonardo Spina Dec 18 '15 at 10:25
  • 2
    No matter how fast or slow you make your program, what you are experiencing is called a [race-condition](http://stackoverflow.com/questions/34510/what-is-a-race-condition). Often these can appear to be solved by adding pauses to slow down one contender in the race. That approach can fail when your computer is under load. The best approach here is to figure out how to get notification and only act when you are sure that the thing you're waiting for is actually finished. – spender Dec 18 '15 at 11:07
  • This isn't really a race condition if there is only one thread making calls – Ross Drew Dec 18 '15 at 11:54
  • 1
    @RossDrew It's a classic race. Two different apps are racing. Race conditions aren't just confined to threading. ["A race condition or race hazard is the behavior of an electronic, software or other system where the output is dependent on the sequence or timing of other uncontrollable events. It becomes a bug when events do not happen in the order the programmer intended. "](https://en.wikipedia.org/wiki/Race_condition) This question fits the definition perfectly (just, not with threads). – spender Dec 18 '15 at 13:47
  • By that logic, denial of service attacks are race conditions though – Ross Drew Dec 18 '15 at 16:26

1 Answers1

3

You can tell your code to wait between statements with Thread.sleep() for example (make sure you use it correctly though)

Thread.sleep(1000); //Wait for a time specified in milliseconds (1000 milliseconds=1 second) 
Community
  • 1
  • 1
Ross Drew
  • 8,163
  • 2
  • 41
  • 53