Package java.util.concurrent

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


public class FjPhaser {

  public static void main(String[] args) throws InterruptedException {
    final Phaser barrier = new Phaser(2);
    final ForkJoinPool pool = new ForkJoinPool();
    ForkJoinTask<?> t1 = pool.submit(ForkJoinTask.adapt(new Runnable() { // T1
      @Override
      public void run() {
        JArmus.register(barrier); // Is using the latch
        try {
          ForkJoinTask.adapt(new Runnable() { // T2
View Full Code Here


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

public class CyclicFj {

  public static void main(String[] args) throws InterruptedException {
    final CyclicBarrier barrier = new CyclicBarrier(2);
    final ForkJoinPool pool = new ForkJoinPool();
    ForkJoinTask<?> t1 = pool.submit(ForkJoinTask.adapt(new Runnable() { // T1
      @Override
      public void run() {
        JArmus.register(barrier); // Is using the latch
        try {
          ForkJoinTask.adapt(new Runnable() { // T2
View Full Code Here

public class FjLatch {

  public static void main(String[] args) throws InterruptedException {
    final CountDownLatch latch = new CountDownLatch(1);
    final ForkJoinPool pool = new ForkJoinPool();
    ForkJoinTask<?> t1 = pool.submit(ForkJoinTask.adapt(new Runnable() { // T1
      @Override
      public void run() {
        JArmus.register(latch); // Is using the latch
        try {
          ForkJoinTask.adapt(new Runnable() { // T2
View Full Code Here

          throw new RuntimeException(e);
        }
      }
    }));
    ForkJoinPool pool = new ForkJoinPool();
    pool.submit(f1.get());
    pool.submit(f2.get());
    f1.get().join();
    f2.get().join();
  }
}
View Full Code Here

        }
      }
    }));
    ForkJoinPool pool = new ForkJoinPool();
    pool.submit(f1.get());
    pool.submit(f2.get());
    f1.get().join();
    f2.get().join();
  }
}
View Full Code Here

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

     * 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));
    }

    /**
     * Calls a closure in a separate thread supplying the given arguments, returning a future for the potential return value.
     */
 
View Full Code Here

        for (int i = 0; i < anArray.length; i++) {
            anArray[i] = r.nextInt(10);
        }
        RecursiveTask<Integer> task = new SumArray(anArray, 0, anArray.length);
        ForkJoinPool mainPool = new ForkJoinPool();
        Future<Integer> future = mainPool.submit(task);
        System.out.println(mainPool.getActiveThreadCount());
        System.out.println(mainPool.getStealCount());
        System.out.println(future.get());
    }
}
View Full Code Here

     
      /*if (pool != null)
         pool.execute(task);*/
     
      if (pool != null) {
         task2 = pool.submit(task);
         try {
            entries = task2.get();
         } catch (InterruptedException | ExecutionException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
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.