How to restart stuck Java program?
<p>My program is fairly large, and because it tends to carry out processes randomly, at times it gets stuck and loops forever. If I were to forcefully stop and restart the program manually, usually (around 85%) of the time, the program completes all commands  and terminates.</p>

<p>Is there a way to make a Java program restart itself after say 20 seconds, if it gets stuck? I tried using the system time to solve the issue, but the problem with this is that if my program gets stuck in a for loop, it does not update the system time until the next iteration.</p>
