Guest User

Untitled

a guest
Jan 22nd, 2018
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.51 KB | None | 0 0
  1. Task calcTask = createCalcTask();
  2.  
  3. ExecutorService executor = Executors.newFixedThreadPool(1);
  4. Future future = executor.submit(calcTask);
  5. try {
  6. future.get();
  7. } catch (ExecutionException ex) {
  8. ex.getCause().printStackTrace();
  9. } catch (InterruptedException e1) {
  10. e1.printStackTrace();
  11. }
  12.  
  13. public Task<Object> createCalcTask() {
  14. return new Task<Object>() {
  15. @Override
  16. protected Object call() throws Exception {
  17. throw new RuntimeException("testE");
  18. }
  19. };
  20. }
Add Comment
Please, Sign In to add comment