org.apache.commons.javaflow.examples.nested.ExecutionOuter.java Source code

Java tutorial

Introduction

Here is the source code for org.apache.commons.javaflow.examples.nested.ExecutionOuter.java

Source

package org.apache.commons.javaflow.examples.nested;

import org.apache.commons.javaflow.api.continuable;
import org.apache.commons.javaflow.api.Continuation;

public class ExecutionOuter implements Runnable {

    @Override
    public @continuable void run() {
        for (int i = 1; i <= 5; i++) {
            System.out.println("Execution " + i);
            for (Continuation cc = Continuation.startWith(new ExecutionInner(i)); null != cc; cc = cc.resume()) {

                System.out.println("\tFrom inner " + cc.value());
                Continuation.suspend(i);
            }
        }
    }

}