How to write interruptable methods
I have a method which, conceptually, looks something like: Object f(Object o1) { Object o2 = longProcess1(o1); Object o3 = longProcess2(o2); return longProcess3(o3); } Where the processes themselves might also be compound: Object longProcess1(Object o1) { Object o2 = longSubProcess1(o1); return longSubProcess2(o2); } And so forth, with the different processes potentially sitting in different modules. Most of the processes are long because they are computationally expensive, not IO-bound. So far so good, but now I want f as a whole to be interruptable. The recommended Java way to do that is to