Created
June 13, 2018 03:05
-
-
Save aruis/ad7d24dd46279b95bb781f80546120f5 to your computer and use it in GitHub Desktop.
vertx 异步转同步
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import io.vertx.core.Vertx | |
import java.util.concurrent.CompletableFuture | |
String sayHello() { | |
def future = new CompletableFuture() | |
Vertx vertx = Vertx.vertx() | |
vertx.setTimer(3000, { | |
future.complete("hello world") | |
}) | |
return future.thenApply({ | |
return it | |
}).get() | |
} | |
println(sayHello()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment