Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Disable new tasks from being submitted
- executorService.shutdown();
- try {
- // Wait a while for existing tasks to terminate
- if (!executorService.awaitTermination(500, TimeUnit.MILLISECONDS)) {
- // Cancel currently executing tasks
- executorService.shutdownNow();
- }
- } catch (InterruptedException e) {
- // (Re-)Cancel if current thread also interrupted
- executorService.shutdownNow();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement