1) Instead of using a while loop in the original function (the one at the beginning of the previous page), change it to an if statement, and run startThread each time where you need to determine the values.
2) Where you need to redefine the values, set a, b, and c back to 0.
In other words, enable the check only when you need it. Otherwise, it will be more complicated, and I can't immediately think of how to loop the cycle.