当前位置: 首页>>代码示例>>Java>>正文


Java ForkJoinPool.getStealCount方法代码示例

本文整理汇总了Java中java.util.concurrent.ForkJoinPool.getStealCount方法的典型用法代码示例。如果您正苦于以下问题:Java ForkJoinPool.getStealCount方法的具体用法?Java ForkJoinPool.getStealCount怎么用?Java ForkJoinPool.getStealCount使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在java.util.concurrent.ForkJoinPool的用法示例。


在下文中一共展示了ForkJoinPool.getStealCount方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: main

import java.util.concurrent.ForkJoinPool; //导入方法依赖的package包/类
/**
 * Usage: NQueensCS [minBoardSize=N] [maxBoardSize=N] [procs=N] [reps=N]
 */
public static void main(String[] args) throws Exception {
    // Board sizes too small: hard to measure well.
    // Board sizes too large: take too long to run.
    final int minBoardSize = intArg(args, "minBoardSize",  8);
    final int maxBoardSize = intArg(args, "maxBoardSize", 15);

    final int procs = intArg(args, "procs", 0);

    for (int reps = intArg(args, "reps", 10); reps > 0; reps--) {
        ForkJoinPool g = (procs == 0) ?
            new ForkJoinPool() :
            new ForkJoinPool(procs);
        lastStealCount = g.getStealCount();
        for (int i = minBoardSize; i <= maxBoardSize; i++)
            test(g, i);
        System.out.println(g);
        g.shutdown();
    }
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:23,代码来源:NQueensCS.java

示例2: test

import java.util.concurrent.ForkJoinPool; //导入方法依赖的package包/类
static void test(ForkJoinPool g, int i) throws Exception {
    boardSize = i;
    int ps = g.getParallelism();
    long start = System.nanoTime();
    NQueensCS task = new NQueensCS(new int[0]);
    g.invoke(task);
    int solutions = task.solutions;
    long time = System.nanoTime() - start;
    double secs = (double) time / NPS;
    if (solutions != expectedSolutions[i])
        throw new Error();
    System.out.printf("NQueensCS %3d", i);
    System.out.printf(" Time: %7.3f", secs);
    long sc = g.getStealCount();
    long ns = sc - lastStealCount;
    lastStealCount = sc;
    System.out.printf(" Steals/t: %5d", ns/ps);
    System.out.println();
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:20,代码来源:NQueensCS.java


注:本文中的java.util.concurrent.ForkJoinPool.getStealCount方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。