Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance. Project price only 1 $
You can buy this project and download/modify it how often you want.
/*
* Copyright 2014-2020 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
* either express or implied. See the License for the specific language
* governing permissions and limitations under the License.
*/
package org.dbflute.helper.thread;
import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.concurrent.Callable;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.Future;
import org.dbflute.helper.message.ExceptionMessageBuilder;
import org.dbflute.helper.thread.exception.CountDownRaceExecutionException;
import org.dbflute.util.Srl;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* @author jflute
* @since 1.0.5A (2013/10/17 Thursday)
*/
public class CountDownRace {
// ===================================================================================
// Definition
// ==========
private static final Logger _log = LoggerFactory.getLogger(CountDownRace.class);
// ===================================================================================
// Attribute
// =========
protected final Map _runnerRequestMap; // map:{entryNumber, parameterObject}
protected final ExecutorService _service;
// ===================================================================================
// Constructor
// ===========
public CountDownRace(int runnerCount) { // assigned by only runner count (without parameter)
if (runnerCount < 1) {
String msg = "The argument 'runnerCount' should not be minus or zero: " + runnerCount;
throw new IllegalArgumentException(msg);
}
_runnerRequestMap = newRunnerRequestMap(runnerCount);
for (int i = 0; i < runnerCount; i++) { // basically synchronized with parameter size
final int entryNumber = i + 1;
_runnerRequestMap.put(entryNumber, null);
}
_service = prepareExecutorService();
}
public CountDownRace(List