Skip to content

Instantly share code, notes, and snippets.

@kasramp
Created October 9, 2018 21:42
Show Gist options
  • Save kasramp/2f42a06a517fbb8cd7b3d42a3f4062d5 to your computer and use it in GitHub Desktop.
Save kasramp/2f42a06a517fbb8cd7b3d42a3f4062d5 to your computer and use it in GitHub Desktop.
Setting timeout for a Callable
try {
futureTask.get(timeoutInSeconds, TimeUnit.SECONDS);
} catch (InterruptedException | ExecutionException ex) {
ex.printStackTrace();
} catch (TimeoutException timeoutException) {
futureTask.cancel(true);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment