Advertisement
Guest User

Untitled

a guest
Dec 10th, 2016
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.73 KB | None | 0 0
  1. public static void main(String[] args) {
  2. final ForkJoinPool test = new ForkJoinPool(1,
  3. ForkJoinPool.defaultForkJoinWorkerThreadFactory, null,true);
  4. final CountDownLatch latch = new CountDownLatch(1);
  5.  
  6. test.execute(() -> {
  7. try {
  8. System.out.println("Sleeping");
  9. Future<Double> f = test.submit(() -> {
  10. latch.await();
  11. return 0d;
  12. });
  13. System.out.println(f.get());
  14. System.out.println("Waking up");
  15. } catch (InterruptedException | ExecutionException e) {
  16. e.printStackTrace();
  17. });
  18.  
  19. System.out.println(test.awaitQuiescence(1, TimeUnit.SECONDS));
  20. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement