Package java.util.concurrent

Examples of java.util.concurrent.ThreadPoolExecutor


   
    if(p != B.length) {
      throw new ArithmeticException("Matrix dimensions must agree.");
    }
   
    ThreadPoolExecutor exec = ThreadPoolServer.getThreadPoolExecutor();
    List<Future<Object>> futures = new ArrayList<Future<Object>>();
   
    for(int ii = 0 ; ii < m ; ii++) {
      final int i = ii;
      futures.add(exec.submit(new Callable<Object>() {

        @Override
        public Object call() throws Exception {
          for(int j = 0 ; j < n ; j++) {
            double sum = 0;
View Full Code Here


   
    if(p != B.length) {
      throw new ArithmeticException("Matrix dimensions must agree.");
    }
   
    ThreadPoolExecutor exec = ThreadPoolServer.getThreadPoolExecutor();
    List<Future<Object>> futures = new ArrayList<Future<Object>>();
   
    for(int ii = 0 ; ii < m ; ii++) {
      final int i = ii;
      futures.add(exec.submit(new Callable<Object>() {

        @Override
        public Object call() throws Exception {
          for(int j = 0 ; j < n ; j++) {
            double sum = 0;
View Full Code Here

   
    if(p != B.length) {
      throw new ArithmeticException("Matrix dimensions must agree.");
    }
   
    ThreadPoolExecutor exec = ThreadPoolServer.getThreadPoolExecutor();
    List<Future<Object>> futures = new ArrayList<Future<Object>>();
   
    for(int ii = 0 ; ii < m ; ii++) {
      final int i = ii;
      futures.add(exec.submit(new Callable<Object>() {

        @Override
        public Object call() throws Exception {
          for(int j = 0 ; j < n ; j++) {
            double sum = 0;
View Full Code Here

          + A[0].length + ", " + n);
    }

    final double[] o = new double[n];

    ThreadPoolExecutor exec = ThreadPoolServer.getThreadPoolExecutor();
    List<Future<Object>> futures = new ArrayList<Future<Object>>();

    for (int ii = 0; ii < m; ii++) {
      final int i = ii;
      futures.add(exec.submit(new Callable<Object>() {

        @Override
        public Object call() throws Exception {
          o[i] = VectorOperations.dot(A[i], x);
          return null;
View Full Code Here

    //max cpu
    int nbcpu = Runtime.getRuntime().availableProcessors();

    //one job per line of the matrix
    int length = l.size();
    ThreadPoolExecutor threadPool = new ThreadPoolExecutor(nbcpu, nbcpu, 10, TimeUnit.SECONDS, new ArrayBlockingQueue<Runnable>(length+2));
    for(int i = length-1 ; i >= 0 ; i--)
    {
      final int index = i;
      Runnable r = new Runnable(){
        @Override
        public void run() {
          TrainingSample<T> s = l.get(index);
          double r = classifier.valueOf(s.sample);
          Evaluation<TrainingSample<T>> e = new Evaluation<TrainingSample<T>>(s, r);
          synchronized(results)
          {
            results.add(e);
          }
        }
      };
     
      threadPool.execute(r);
    }

    threadPool.shutdown();
    try {
      threadPool.awaitTermination(Integer.MAX_VALUE, TimeUnit.DAYS);
    } catch (InterruptedException e) {
      debug.println(1, "Evaluator error - result corrupted");
      e.printStackTrace();
    }
 
View Full Code Here

    if (C.length != m) {
      throw new ArithmeticException("Matrix Dimension must agree : "
          + C.length + ", " + m);
    }
   
    ThreadPoolExecutor exec = ThreadPoolServer.getThreadPoolExecutor();
    List<Future<Object>> futures = new ArrayList<Future<Object>>();
    final double[] o = C;
   
    for (int ii = 0; ii < m; ii++) {
      final int i = ii;
      futures.add(exec.submit(new Callable<Object>() {

        @Override
        public Object call() throws Exception {
          o[i] = VectorOperations.dot(A[i], x);
          return null;
View Full Code Here

        listOfClassifiers.add(null);
      }
    }
    debug.println(1, "Number of Classes: " + nbclasses);

    ThreadPoolExecutor ex = ThreadPoolServer.getThreadPoolExecutor();
    List<Future<Object>> futures = new ArrayList<>();

    // learning N one against all classifiers
    for (int id = 0; id < nbclasses; id++) {
      final int i = id;
      futures.add(ex.submit(new Callable<Object>() {

        @Override
        public Object call() throws Exception {

          Classifier<T> cls = null;
View Full Code Here

      return 0;

    final double[] values = new double[listOfClassifiers.size()];

    if (nbclasses > 2 * Runtime.getRuntime().availableProcessors()) {
      ThreadPoolExecutor ex = ThreadPoolServer.getThreadPoolExecutor();
      List<Future<Object>> futures = new ArrayList<>(
          listOfClassifiers.size());
      for (int i = 0; i < listOfClassifiers.size(); i++) {
        final int id = i;
        futures.add(ex.submit(new Callable<Object>() {

          @Override
          public Object call() throws Exception {
            values[id] = listOfClassifiers.get(id).valueOf(t);
            return null;
View Full Code Here

        this.processTime = metricRegistry.timer(name(OutputBufferProcessor.class, "processTime"));
    }

    private ExecutorService executorService(final MetricRegistry metricRegistry, final String nameFormat,
                                            final int corePoolSize, final int maxPoolSize, final int keepAliveTime) {
        return new InstrumentedExecutorService(new ThreadPoolExecutor(
                corePoolSize, maxPoolSize, keepAliveTime, TimeUnit.MILLISECONDS,
                new LinkedBlockingQueue<Runnable>(), threadFactory(metricRegistry, nameFormat)), metricRegistry);
    }
View Full Code Here

                    latch.countDown();
                }
            }, "topic" + runs);

            ArrayBlockingQueue<Runnable> workQueue = new ArrayBlockingQueue<Runnable>(BATCH_SIZE+1);
            ThreadPoolExecutor executor = new ThreadPoolExecutor(1,
                    1,
                    1000,
                    TimeUnit.MILLISECONDS, workQueue);


            for (int i = 0; i < BATCH_SIZE; i++) {
                final String topicString = "topic"+runs;
                final Hashtable<String,Object> localProperties = new Hashtable<String, Object>();
                localProperties.put(topicString,i);
                workQueue.add(new Runnable() {
                    @Override
                    public void run() {
                        send(topicString, localProperties, true);
                    }
                });
            }

            long startTime = System.nanoTime();
            executor.prestartAllCoreThreads();

            try {
                latch.await();
            } catch (InterruptedException e) {
                e.printStackTrace();
View Full Code Here

TOP

Related Classes of java.util.concurrent.ThreadPoolExecutor

Copyright © 2018 www.massapicom. 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.