Example usage for io.vertx.core WorkerExecutor executeBlocking

List of usage examples for io.vertx.core WorkerExecutor executeBlocking

Introduction

In this page you can find the example usage for io.vertx.core WorkerExecutor executeBlocking.

Prototype

<T> Future<@Nullable T> executeBlocking(Handler<Promise<T>> blockingCodeHandler, boolean ordered);

Source Link

Document

Same as #executeBlocking(Handler,boolean,Handler) but with an handler called when the operation completes

Usage

From source file:examples.CoreExamples.java

License:Open Source License

public void workerExecutor1(Vertx vertx) {
    WorkerExecutor executor = vertx.createSharedWorkerExecutor("my-worker-pool");
    executor.executeBlocking(future -> {
        // Call some blocking API that takes a significant amount of time to return
        String result = someAPI.blockingMethod("hello");
        future.complete(result);//from  ww w .java 2 s .com
    }, res -> {
        System.out.println("The result is: " + res.result());
    });
}