本文整理汇总了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();
}
}
示例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();
}