8 Replies - 1252 Views - Last Post: 17 August 2010 - 03:47 PM Rate Topic: -----

#1 arvi   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 07-May 07

Infinite Loop

Posted 17 August 2010 - 02:51 PM

I want to stop in 10 minutes automatically any infinite loop problem.
Is This A Good Question/Topic? 0
  • +

Replies To: Infinite Loop

#2 KYA   User is offline

  • Wubba lubba dub dub!
  • member icon

Reputation: 3213
  • View blog
  • Posts: 19,241
  • Joined: 14-September 07

Re: Infinite Loop

Posted 17 August 2010 - 02:53 PM

1. Set up a timer.
2. break; after ten minutes have elapsed.
Was This Post Helpful? 0
  • +
  • -

#3 MadScientist305   User is offline

  • New D.I.C Head

Reputation: 6
  • View blog
  • Posts: 44
  • Joined: 26-December 09

Re: Infinite Loop

Posted 17 August 2010 - 02:55 PM

You can use a Timer object that breaks after 10 minutes.
Was This Post Helpful? 0
  • +
  • -

#4 arvi   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 07-May 07

Re: Infinite Loop

Posted 17 August 2010 - 03:01 PM

But How to set up a timer?
Was This Post Helpful? 0
  • +
  • -

#5 Nakor   User is offline

  • Professional Lurker
  • member icon

Reputation: 448
  • View blog
  • Posts: 1,504
  • Joined: 28-April 09

Re: Infinite Loop

Posted 17 August 2010 - 03:37 PM

java.util.Timer
Was This Post Helpful? 0
  • +
  • -

#6 pbl   User is offline

  • There is nothing you can't do with a JTable
  • member icon

Reputation: 8381
  • View blog
  • Posts: 31,956
  • Joined: 06-March 08

Re: Infinite Loop

Posted 17 August 2010 - 03:42 PM

This would be an horrible patch
Better to investigate why your program is going into an infinite loop

You can write code with try/catch statements for every 5 lines of code. Not a very good practice at all.
Was This Post Helpful? 1
  • +
  • -

#7 macosxnerd101   User is offline

  • Games, Graphs, and Auctions
  • member icon




Reputation: 12800
  • View blog
  • Posts: 45,992
  • Joined: 27-December 08

Re: Infinite Loop

Posted 17 August 2010 - 03:44 PM

As a general practice, better to write code that won't blow up than to patch together a bunch of safeguards in case of every blowup. You'll have less code that is more efficient this way.
Was This Post Helpful? 0
  • +
  • -

#8 m-e-g-a-z   User is offline

  • Winning
  • member icon


Reputation: 497
  • View blog
  • Posts: 1,457
  • Joined: 19-October 09

Re: Infinite Loop

Posted 17 August 2010 - 03:47 PM

I've got a feeling if code was provided, it could be solved easier and more helpful.
Was This Post Helpful? 0
  • +
  • -

#9 pbl   User is offline

  • There is nothing you can't do with a JTable
  • member icon

Reputation: 8381
  • View blog
  • Posts: 31,956
  • Joined: 06-March 08

Re: Infinite Loop

Posted 17 August 2010 - 03:47 PM

and it means there if at least one error in your logic. Hope you are not writing a cardiac monitoring system :)
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1