Skip to content

Instantly share code, notes, and snippets.

@purplefox
Last active May 10, 2017 17:31
Show Gist options
  • Save purplefox/e27794e014c66a561e9c896bfdf269bb to your computer and use it in GitHub Desktop.
Save purplefox/e27794e014c66a561e9c896bfdf269bb to your computer and use it in GitHub Desktop.
vertx.executeBlocking(fut -> {
Thread worker = Thread.currentThread();
AtomicBoolean complete = new AtomicBoolean();
long id = vertx.setTimer(TIMEOUT, tid -> {
if (!complete.get()) {
worker.interrupt();
}
});
try {
// Execute the regex here with the special CharSequence
executeRegex();
complete.set(true);
vertx.cancelTimer(id);
fut.complete(null);
} catch (RuntimeException e) {
// it timed out
fut.fail(e);
}
}, res -> {
System.out.println("Timed out ? " + res.failed());
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment