當前位置: 首頁>>代碼示例>>Java>>正文


Java ForkJoinTask.join方法代碼示例

本文整理匯總了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);
}
 
開發者ID:mbuzdalov,項目名稱:non-dominated-sorting,代碼行數:38,代碼來源:AbstractJFBSorting.java

示例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();
}
 
開發者ID:lambdalab-mirror,項目名稱:jdk8u-jdk,代碼行數:9,代碼來源:MergeSort.java


注:本文中的java.util.concurrent.ForkJoinTask.join方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。