Example usage for org.apache.commons.javaflow.api Continuation resume

List of usage examples for org.apache.commons.javaflow.api Continuation resume

Introduction

In this page you can find the example usage for org.apache.commons.javaflow.api Continuation resume.

Prototype

public Continuation resume() 

Source Link

Document

Resumes the execution of the specified continuation from where it's left off.

Usage

From source file:org.apache.commons.javaflow.examples.again.AgainExample.java

public static void main(final String[] argv) throws Exception {
    Continuation cc = Continuation.startWith(new Execution());
    System.out.println("In main loop after prologue");
    cc = cc.resume(); // will loop in Execution due to call to again()
    System.out.println("In main done");
    System.out.println("===");
}

From source file:org.apache.commons.javaflow.examples.cancel.CancelExample.java

public static void main(final String[] argv) throws Exception {
    Continuation cc = Continuation.startSuspendedWith(new Execution());
    cc = cc.resume();
    System.out.println("In main, first stop, let's loop (cc.value = " + cc.value() + ") ");
    for (int i = 1; i <= 3; i++) {
        cc = cc.resume();/* w  w w  . j  a va 2s  .  c  o m*/
        System.out.println("In main after #" + i + " suspend (cc.value = " + cc.value() + ") ");
    }
    // This will gracefully complete continuation -- finally blocks will be executed
    cc.terminate();
    System.out.println("In main after destroy");
    System.out.println("===");
}

From source file:org.apache.commons.javaflow.examples.lambdas.LambdasExampleMinimal.java

public static void main(final String[] argv) throws Exception {

    Continuation cc = Continuations.start(() -> {
        for (int i = 1; i <= 5; i++) {
            System.out.println("Exe before suspend");
            Continuation.suspend(i);/*from   w w w  .jav  a2 s  . co m*/
            System.out.println("Exe after suspend");
        }
    });

    for (; null != cc; cc = cc.resume()) {
        System.out.println("Interrupted " + cc.value());
    }

    System.out.println("===");
}