Skip to content

Instantly share code, notes, and snippets.

@aruis
Created June 13, 2018 03:05
Show Gist options
  • Save aruis/ad7d24dd46279b95bb781f80546120f5 to your computer and use it in GitHub Desktop.
Save aruis/ad7d24dd46279b95bb781f80546120f5 to your computer and use it in GitHub Desktop.
vertx 异步转同步
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