Package java.util.concurrent

Examples of java.util.concurrent.ExecutorService.awaitTermination()


            // by virtue of the Callable redefinition above I can cast
            throw (IOException) e.getCause();
        } finally {
            executor.shutdownNow();
            try {
                executor.awaitTermination(timeout, unit);
            } catch (InterruptedException e) {
                // ignore
            }
        }
    }
View Full Code Here


        } catch (ExecutionException e) {
            throw e;
        } finally {
            executor.shutdownNow();
            try {
                executor.awaitTermination(timeout, unit);
            } catch (InterruptedException e) {
                // ignore
            }
        }
    }
View Full Code Here

         Runnable validMover = new ValidMover(caches, barrier, threadIndex, state, operation);
         exec.execute(validMover);
      }
      exec.shutdown();
      try {
         exec.awaitTermination(5, TimeUnit.MINUTES);
      } catch (InterruptedException e) {
         e.printStackTrace();
         assert false : e.getMessage();
      }
      assert !failed.get() : failureMessage;
View Full Code Here

        List<Future<String>> fs = new LinkedList<Future<String>>();
        for (Callable<String> c : cs) {
            fs.add(executor.submit(c));
        }
        executor.shutdown();
        executor.awaitTermination(10, TimeUnit.SECONDS);

        // get all results in order to verify if any of the threads has thrown
        // an exception
        for (Future<String> f : fs) {
            f.get();
View Full Code Here

      KeepAlive keepAlive = startCounterKeepAlive(pool, context);

      proc.waitFor();
      keepAlive.sendReport = false;
      pool.shutdown();
      if (!pool.awaitTermination(WATCHER_TIMEOUT_SECS, TimeUnit.SECONDS))
        pool.shutdownNow();

      writeExitValue(conf, proc.exitValue(), statusdir);
      JobState state = new JobState(context.getJobID().toString(), conf);
      state.setExitValue(proc.exitValue());
View Full Code Here

        if (createdExecutor) {
            ExecutorService e = (ExecutorService) executor;
            e.shutdown();
            while (!e.isTerminated()) {
                try {
                    e.awaitTermination(Integer.MAX_VALUE, TimeUnit.SECONDS);
                } catch (InterruptedException e1) {
                    // Ignore; it should end shortly.
                }
            }
        }
View Full Code Here

                } catch (NullPointerException ex) {
                    // Some JDK throws NPE here, but shouldn't.
                }

                try {
                    if (es.awaitTermination(100, TimeUnit.MILLISECONDS)) {
                        break;
                    }
                } catch (InterruptedException ex) {
                    // Ignore.
                }
View Full Code Here

                            }
                        }
                    );
            }
            service.shutdown();
            Assert.assertTrue(service.awaitTermination(10, TimeUnit.SECONDS));
        }
        finally
        {
            client.close();
        }
View Full Code Here

    if (executorSvc != null) {
      List<Runnable> tasksLeft = executorSvc.shutdownNow();
      LOG.info(tasksLeft.size() + " tasks never executed for msgType: " + type + ". tasks: "
          + tasksLeft);
      try {
        if (!executorSvc.awaitTermination(200, TimeUnit.MILLISECONDS)) {
          LOG.error("executor-service for msgType: " + type
              + " is not fully terminated in 200ms. will disconnect helix-participant");
          throw new HelixException("fail to unregister msg-handler for msgType: " + type);
        }
      } catch (InterruptedException e) {
View Full Code Here

            ExecutorService executor = Executors.newFixedThreadPool(nThreads);
            for (int j = 0; j < nThreads; j++) {
                executor.submit(new AddAndUpdateNodesTask(docStore, "node" + nPrefix[j], nNodes));
            }
            executor.shutdown();
            executor.awaitTermination(1, TimeUnit.MINUTES);

            long end = System.currentTimeMillis();
            log("Done: " + (end - start) + "ms");

        }
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.