Package java.util.concurrent

Examples of java.util.concurrent.ForkJoinPool$ManagedBlocker


    /**
     * 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


                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

    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

     
    }
  }

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

        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

  }

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

        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

    }

    private static void test1() {
        // -Djava.util.concurrent.ForkJoinPool.common.parallelism=5

        ForkJoinPool commonPool = ForkJoinPool.commonPool();
        System.out.println(commonPool.getParallelism());
    }
View Full Code Here

        addExpectation(expectations, client, 200, 3600, createPackageFeed("feed-19", 200, 3601));
        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

  /**Render that uses the given thread pool for parallel operations.
   *
   * @param pool -- Thread pool to use.  Null to create a pool
   * **/
  public ParallelRenderer(ForkJoinPool pool, int threadLoad, long transferTaskSize) {
    this.pool = pool != null ? pool : new ForkJoinPool(RENDER_POOL_SIZE);
    this.threadLoad = threadLoad > 0 ? threadLoad : RENDER_THREAD_LOAD;
    this.transferTaskSize = transferTaskSize > 0 ? transferTaskSize : DEFAULT_TRANSFER_TASK_SIZE;
  }
View Full Code Here

TOP

Related Classes of java.util.concurrent.ForkJoinPool$ManagedBlocker

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.