Advertisement
Guest User

Untitled

a guest
Mar 22nd, 2019
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.41 KB | None | 0 0
  1. // Disable new tasks from being submitted
  2. executorService.shutdown();
  3. try {
  4. // Wait a while for existing tasks to terminate
  5. if (!executorService.awaitTermination(500, TimeUnit.MILLISECONDS)) {
  6. // Cancel currently executing tasks
  7. executorService.shutdownNow();
  8. }
  9. } catch (InterruptedException e) {
  10. // (Re-)Cancel if current thread also interrupted
  11. executorService.shutdownNow();
  12. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement