wood burning stoves 2.0*
The moose likes Beginning Java and the fly likes knowing process is in infininte loop Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "knowing process is in infininte loop" Watch "knowing process is in infininte loop" New topic
Author

knowing process is in infininte loop

Puneet N Vyas
Ranch Hand

Joined: Sep 20, 2007
Posts: 61
how can i write a java program which demostrate that a process is in a infininte loop and when it comes under such condition,our program detects it and suitable course of action
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 37907
    
  22
You need Knaster's and Tarski's lattice theory, and you demonstrate that the lowest fixed point of the transitive opening of your loop converges on "abort." And if you can understand that lot, you are doing quite well.

Or to put it simply: you can't. Java doesn't support the loop variant of languages like B or Eiffel, so you cannot actually test for an infinite loop.

You could try putting an int counter in the loop, incrementing it each repetition, and if it goes negative call a break statement (or better, throw an Exception). That's as near as I can think of to test for an infinite loop.
Bill Shirley
Ranch Hand

Joined: Nov 08, 2007
Posts: 457
In general it's not solvable.
In practicality, you'd have to have control over the JVM.
Heuristically, it's a difficult problem where you'll have to weigh your false positives v. your false negatives - you're going to get some.


Bill Shirley - bshirley - frazerbilt.com
if (Posts < 30) you.read( JavaRanchFAQ);
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: knowing process is in infininte loop
 
Similar Threads
Reducing fractions problem
Help! Need to write out a amount after string has certain values in it. Must add and read file.
Reading from STDIN
Why an "engine" for workflow ?
Websphere scheduler