-
-
Save kasramp/2f42a06a517fbb8cd7b3d42a3f4062d5 to your computer and use it in GitHub Desktop.
Setting timeout for a Callable
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
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