Examples of ForkJoinPool


Examples of java.util.concurrent.ForkJoinPool

public class FjLatchInvokeAll {

  public static void main(String[] args) throws InterruptedException {
    final CountDownLatch latch = new CountDownLatch(1);
    final ForkJoinPool pool = new ForkJoinPool();
    pool.invoke(ForkJoinTask.adapt(new Runnable() { // T
      @Override
      public void run() {
        ForkJoinTask.invokeAll(Arrays.asList(ForkJoinTask.adapt(new Runnable() {
          @Override
          public void run() {
View Full Code Here

Examples of java.util.concurrent.ForkJoinPool

        }
      }
    };
    ForkJoinTask<?> t1 = ForkJoinTask.adapt(runnable);
    cell.set(t1);
    ForkJoinPool pool = new ForkJoinPool();
    pool.submit(t1);
    t1.get();
  }
View Full Code Here

Examples of java.util.concurrent.ForkJoinPool

     * Allows timeouts for async operations
     */
    private static final GeneralTimer timer = GParsConfig.retrieveDefaultTimer("GParsTimeoutTimer", true);

    private static ForkJoinPool retrievePool() {
        final ForkJoinPool pool = (ForkJoinPool) GParsPool.retrieveCurrentPool();
        if (pool == null) throw new IllegalStateException("No ForkJoinPool available for the current thread");
        return pool;
    }
View Full Code Here

Examples of java.util.concurrent.ForkJoinPool

    /**
     * schedules the supplied closure for processing in the underlying thread pool.
     */
    public static <T> Future<T> callParallel(final Closure<T> task) {
        final ForkJoinPool pool = (ForkJoinPool) GParsPool.retrieveCurrentPool();
        if (pool == null) throw new IllegalStateException("No ForkJoinPool available for the current thread.");
        return pool.submit(new CallAsyncTask<T>(task));
    }
View Full Code Here

Examples of java.util.concurrent.ForkJoinPool

                System.err.println(Pool.UNCAUGHT_EXCEPTION_OCCURRED_IN_GPARS_POOL + t.getName());
                e.printStackTrace(System.err);
            }
        };

        return new ForkJoinPool(poolSize, ForkJoinPool.defaultForkJoinWorkerThreadFactory, uncaughtExceptionHandler, false);
    }
View Full Code Here

Examples of java.util.concurrent.ForkJoinPool

    private static volatile ForkJoinPool defaultExecutor;
    /** Lock for on-demand initialization of defaultExecutor */
    private static final Object poolLock = new Object();

    static ForkJoinPool defaultExecutor() {
        ForkJoinPool p = defaultExecutor; // double-check
        if (p == null) {
            synchronized (poolLock) {
                p = defaultExecutor;
                if (p == null) {
                    // use ceil(7/8 * ncpus)
                    int nprocs = Runtime.getRuntime().availableProcessors();
                    int nthreads = nprocs - (nprocs >>> 3);
                    defaultExecutor = p = new ForkJoinPool(nthreads);
                }
            }
        }
        return p;
    }
View Full Code Here

Examples of java.util.concurrent.ForkJoinPool

     
    }
  }

  private static void invokeTasks(){
    ForkJoinPool pool = new ForkJoinPool();
   
    for(File child : foldersToScan){
      pool.invoke(new Crawler(child));
       
    }
  }
View Full Code Here

Examples of java.util.concurrent.ForkJoinPool

        List<CLCommandQueue> list = new ArrayList<CLCommandQueue>(queues);

        CLThreadFactory factory = new CLThreadFactory(list);
        int size = list.size();

        ExecutorService service = new ForkJoinPool(size, factory, null, false);
        return new CLForkJoinPool(service, list);
    }
View Full Code Here

Examples of java.util.concurrent.ForkJoinPool

  }

  @Override
  public void afterPropertiesSet() {
    this.forkJoinPool = (this.commonPool ? ForkJoinPool.commonPool() :
        new ForkJoinPool(this.parallelism, this.threadFactory, this.uncaughtExceptionHandler, this.asyncMode));
  }
View Full Code Here

Examples of java.util.concurrent.ForkJoinPool

        return matchCount;
    }

    public static Map<Long, Integer> match(String regex, String input, GraphDatabaseService db, GraphManager graphManager) {
        Map<Long, Integer> matches = new HashMap<>();
        ForkJoinPool pool = new ForkJoinPool();
        pool.invoke(new PatternMatcher(regex, input, matches, db, graphManager));

        // Cleaning up after yourself is important
        pool.shutdown();
        try {
            pool.awaitTermination(5, TimeUnit.SECONDS);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }

        return matches;
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.