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

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

Introduction

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

Prototype

public static Continuation startSuspendedWith(final Runnable target) 

Source Link

Document

Creates a new Continuation object from the specified Runnable object.

Usage

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();// w w w .ja  va 2  s  . c  o  m
    System.out.println("In main, first stop, let's loop (cc.value = " + cc.value() + ") ");
    for (int i = 1; i <= 3; i++) {
        cc = cc.resume();
        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("===");
}