Package java.util.concurrent

Examples of java.util.concurrent.ThreadPoolExecutor.execute()


        Thread.sleep(10000);
               
        executor.execute(new HelloWorker(helloPort, "Barry", "Jameson", startSignal, helloDoneSignal));
        executor.execute(new HelloWorker(helloPort, "Harry", "", startSignal, helloDoneSignal));
        executor.execute(new HelloWorker(helloPort, "Rob", "Davidson", startSignal, helloDoneSignal));
        executor.execute(new HelloWorker(helloPort, "James", "ServiceMix", startSignal, helloDoneSignal));
       
               
        helloDoneSignal.await(60, TimeUnit.SECONDS);
        executor.shutdownNow();
        System.out.println("Completed : " + (5 - helloDoneSignal.getCount()));
View Full Code Here


    ThreadPoolExecutor executor = executors.get(root);
    if (executor == null) {
      throw new RuntimeException("Cannot find root " + root
          + " for execution of task " + task);
    } else {
      executor.execute(task);
    }
  }
 
  /**
   * Gracefully shut down all ThreadPool. Will wait for all deletion
View Full Code Here

        Path regionPath = regionStatus.getPath();
        if (null == regionPath) {
          continue;
        }

        tpe.execute(new FSRegionScanner(fs, regionPath,
            regionToBestLocalityRSMapping, regionDegreeLocalityMapping));
      }
    } finally {
      tpe.shutdown();
      int threadWakeFrequency = conf.getInt(HConstants.THREAD_WAKE_FREQUENCY,
View Full Code Here

      if (priority != Store.NO_PRIORITY) {
        cr.setPriority(priority);
      }
      ThreadPoolExecutor pool = s.throttleCompaction(cr.getSize())
          ? largeCompactions : smallCompactions;
      pool.execute(cr);
      if (LOG.isDebugEnabled()) {
        String type = (pool == smallCompactions) ? "Small " : "Large ";
        LOG.debug(type + "Compaction requested: " + cr
            + (why != null && !why.isEmpty() ? "; Because: " + why : "")
            + "; " + this);
View Full Code Here

        }
        if (p == null) {
            throw new IllegalStateException("ThreadPool has been stopped");
        }
        Runnable task = new ContextClassLoaderRunnable(command, classLoader);
        p.execute(task);
    }

    private synchronized void startWork(String consumerName) {
        Integer test = (Integer) clients.get(consumerName);
        if (test == null) {
View Full Code Here

    ThreadPoolExecutor executor = executors.get(root);
    if (executor == null) {
      throw new RuntimeException("Cannot find root " + root
          + " for execution of task " + task);
    } else {
      executor.execute(task);
    }
  }
 
  /**
   * Gracefully shut down all ThreadPool. Will wait for all deletion
View Full Code Here

    ThreadPoolExecutor executor = executors.get(root);
    if (executor == null) {
      throw new RuntimeException("Cannot find root " + root
          + " for execution of task " + task);
    } else {
      executor.execute(task);
    }
  }
 
  /**
   * Gracefully shut down all ThreadPool. Will wait for all deletion
View Full Code Here

            workers.add(new BookWorker("http://localhost:" + port + getBaseAddress() + pathSegment + "/" + x,
                                       Integer.toString(x),
                                       "CXF in Action" + x, startSignal, doneSignal));
        }
        for (BookWorker w : workers) {
            executor.execute(w);
        }
       
        startSignal.countDown();
        doneSignal.await(60, TimeUnit.SECONDS);
        executor.shutdownNow();      
View Full Code Here

        ThreadPoolExecutor executor = new ThreadPoolExecutor(1, 1, 0, TimeUnit.SECONDS,
                                                             new ArrayBlockingQueue<Runnable>(10));
        CountDownLatch startSignal = new CountDownLatch(1);
        CountDownLatch doneSignal = new CountDownLatch(1);
       
        executor.execute(new BookWorker("http://localhost:" + PORT + "/bookstore/" + pathSegment + "/1",
                                        "1",
                                        "CXF in Action1", startSignal, doneSignal));
        startSignal.countDown();
        doneSignal.await(60, TimeUnit.SECONDS);
        executor.shutdownNow();
View Full Code Here

                buffer[segmentSizeIter] = input.next();
            final int segmentSize = segmentSizeIter;
            logger.info("Segment " + segmentId + ": sort buffer filled...adding to sort queue.");

            // sort and write out asynchronously
            executor.execute(new Runnable() {

                public void run() {
                    logger.info("Segment " + segmentId + ": sorting buffer.");
                    long start = System.currentTimeMillis();
                    Arrays.sort(buffer, 0, segmentSize, comparator);
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.