本文整理汇总了Java中java.util.concurrent.ForkJoinTask.join方法的典型用法代码示例。如果您正苦于以下问题:Java ForkJoinTask.join方法的具体用法?Java ForkJoinTask.join怎么用?Java ForkJoinTask.join使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.util.concurrent.ForkJoinTask
的用法示例。
在下文中一共展示了ForkJoinTask.join方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: helperBMain
import java.util.concurrent.ForkJoinTask; //导入方法依赖的package包/类
private int helperBMain(int goodFrom, int goodUntil, int weakFrom, int weakUntil, int obj, int tempFrom, int tempUntil) {
int medianGood = ArrayHelper.transplant(transposedPoints[obj], indices, goodFrom, goodUntil, medianSwap, tempFrom);
double goodMinObj = ArrayHelper.min(medianSwap, tempFrom, medianGood);
int medianWeak = ArrayHelper.transplant(transposedPoints[obj], indices, weakFrom, weakUntil, medianSwap, medianGood);
double weakMaxObj = ArrayHelper.max(medianSwap, medianGood, medianWeak);
if (weakMaxObj < goodMinObj) {
return weakUntil;
}
double goodMaxObj = ArrayHelper.max(medianSwap, tempFrom, medianGood);
double weakMinObj = ArrayHelper.min(medianSwap, medianGood, medianWeak);
if (goodMaxObj <= weakMinObj) {
return helperB(goodFrom, goodUntil, weakFrom, weakUntil, obj - 1, tempFrom, tempUntil);
}
double median = ArrayHelper.destructiveMedian(medianSwap, tempFrom, medianWeak);
long goodSplit = splitMerge.splitInThree(transposedPoints[obj], indices, tempFrom, goodFrom, goodUntil, median, goodMinObj, goodMaxObj);
int goodMidL = SplitMergeHelper.extractMid(goodSplit);
int goodMidR = SplitMergeHelper.extractRight(goodSplit);
long weakSplit = splitMerge.splitInThree(transposedPoints[obj], indices, tempFrom, weakFrom, weakUntil, median, weakMinObj, weakMaxObj);
int weakMidL = SplitMergeHelper.extractMid(weakSplit);
int weakMidR = SplitMergeHelper.extractRight(weakSplit);
int tempMid = (tempFrom + tempUntil) >>> 1;
ForkJoinTask<Integer> newWeakMidLTask = null;
if (pool != null && goodMidL - goodFrom + weakMidL - weakFrom > FORK_JOIN_THRESHOLD) {
newWeakMidLTask = helperBAsync(goodFrom, goodMidL, weakFrom, weakMidL, obj, tempFrom, tempMid).fork();
}
int newWeakUntil = helperB(goodMidR, goodUntil, weakMidR, weakUntil, obj, tempMid, tempUntil);
int newWeakMidL = newWeakMidLTask != null
? newWeakMidLTask.join()
: helperB(goodFrom, goodMidL, weakFrom, weakMidL, obj, tempFrom, tempMid);
splitMerge.mergeTwo(indices, tempFrom, goodFrom, goodMidL, goodMidL, goodMidR);
newWeakUntil = splitMerge.mergeTwo(indices, tempFrom, weakMidL, weakMidR, weakMidR, newWeakUntil);
newWeakUntil = helperB(goodFrom, goodMidR, weakMidL, newWeakUntil, obj - 1, tempFrom, tempUntil);
splitMerge.mergeTwo(indices, tempFrom, goodFrom, goodMidR, goodMidR, goodUntil);
return splitMerge.mergeTwo(indices, tempFrom, weakFrom, newWeakMidL, weakMidL, newWeakUntil);
}
示例2: sort
import java.util.concurrent.ForkJoinTask; //导入方法依赖的package包/类
/**
* Sorts all the elements of the given array using the ForkJoin framework
* @param array the array to sort
*/
public void sort(int[] array) {
ForkJoinTask<Void> job = pool.submit(new MergeSortTask(array, 0, array.length));
job.join();
}