If I understand the problem, your process is linear - so if at some point a piece of code gets 'stuck', and that is beyond your control (for example a 3rd party library or a Runtime.exec() call),...