!7 cprint { class State extends ProbabilisticMachine2.State { Runnable continuation; public State makeDescendant() { new State s; prepareDescendant(s); s.continuation = continuation; ret s; } void doneWithSubroutine { if (continuation == null) ret; State s = makeDescendant(); s.continuation = null; switchTo(s); continuation.run(); } void step { doneWithSubroutine(); } } start-thread { new ProbabilisticMachine2 pm; State s = new { run { print("Hello"); doneWithSubroutine(); } }; s.continuation = r { print("World"); }; pm.addState(s); pm.onRunningState = st -> { print("Running state " + st); }; pm.onRanState = st -> { print("Ran state " + st); }; stepAllWithStats(pm); } }