Solution previously mentioned by Luiggi Mendoza: How to avoid stack overflow error
When you call reset, it calls method1, it calls method2, it calls method3 and it calls either reset or method2 both causing infinite cycle in recursion.
You probably want:
if (jobDone) return; // here the cycle realy closes
instead of
if (jobDone) reset(); //here the do _not_ close
In case you realy want infinite cycling of your code this will not cause SO due to method calling of reset or methodi:
// assuming jobDone is actually a method, you might need this variable
boolean startReset = true;
while (true) {
if (startReset) {
//sets all variables to initial values
//clears all arrays
//doSomeStuff from method1;
}
//doStuff from method2
//doStuff
startReset = jobDone;
}
}