Package java.util.concurrent

Examples of java.util.concurrent.ForkJoinPool.invoke()


   */
  public static void main(String[] args) throws InterruptedException, ExecutionException {
   
    ForkJoinPool pool = new ForkJoinPool();
    Task executionTask = new Task(1000000000.0);
    pool.invoke(executionTask);
    System.out.println(pool.toString());
    System.out.println(String.format("Full execution time is %d", executionTask.get()));
    pool.shutdown();
  }

View Full Code Here


    Task task=new Task("Task",array,0,array.length);
   
    /*
     * Send the task to the pool
     */
    pool.invoke(task);
   
    /*
     * Shutdown the pool
     */
    pool.shutdown();
 
View Full Code Here

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

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

  private static List<File> getFoldersIn(File root){
View Full Code Here

    }

    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);
View Full Code Here

        addExpectation(expectations, client, 200, 3800, createPackageFeed("feed-20", 200, 3801));
        context.checking(expectations);
        GetRemotePackageFeedAction instance = new GetRemotePackageFeedAction(200, arrayList, 0, 4000, clientFactory);
        //WHEN
        ForkJoinPool pool = new ForkJoinPool();
        pool.invoke(instance);
        //THEN
        context.assertIsSatisfied();
        assertThat(arrayList.size(), is(equalTo(4000)));
    }
View Full Code Here

 
  /**Bounds calculation.  Is run in parallel using the tuning parameters of ParallelRenderer.**/
  public Rectangle2D bounds() {
    if (bounds == null) {
      ForkJoinPool pool = new ForkJoinPool(Runtime.getRuntime().availableProcessors());
      bounds = pool.invoke(
          new BoundsTask<>(
              this,
              ParallelRenderer.RENDER_POOL_SIZE
                * ParallelRenderer.RENDER_THREAD_LOAD));
    }
 
View Full Code Here

 
 
  public Rectangle2D bounds(int m) {
    int procs = Runtime.getRuntime().availableProcessors();
    ForkJoinPool pool = new ForkJoinPool(procs);
    bounds = pool.invoke(new BoundsTask<>(this, m*procs));
    return bounds;
  }
   
  @Override
  public Glyphset<G, I> segmentAt(int count, int segId) throws IllegalArgumentException {
View Full Code Here

    Collections.shuffle(lu);
    Update[] updates = lu.toArray(new Update[0]); // Avoid allocation by passing
                                                  // zero-sized array
    MicroBlogUpdateSorter sorter = new MicroBlogUpdateSorter(updates);
    ForkJoinPool pool = new ForkJoinPool(4);
    pool.invoke(sorter);

    for (Update u : sorter.getResult()) {
      System.out.println(u);
    }
  }
View Full Code Here

        int nThreads = Runtime.getRuntime().availableProcessors();
        System.out.println(nThreads);
        SelectMaxInArray t = new SelectMaxInArray(test);
        ForkJoinPool pool = new ForkJoinPool(nThreads);
        Long start = System.nanoTime();
        pool.invoke(t);
        Long end = System.nanoTime();
        long result = t.result;
        System.out.println("Done. Result: " + result + "time1 : " + (end - start));
        Long start2 = System.nanoTime();
        long result2 = test2.solveSequentially();
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.