class Holder {

		static final ExecutorHelper INSTANCE = new ExecutorHelper();

	}

	public static ExecutorHelper loadInstance() {
		return Holder.INSTANCE;
	}

	/**
	 *
	 * <p>
	 * @param pool 需要关闭的线程组.
	 */
	public void shutdownAwaitTermination(ExecutorService pool) {
		shutdownAwaitTermination(pool, 60L);
	}

	/**
	 * <p>
	 * 关闭ExecutorService的线程管理者
	 * <p>
	 * @param pool 需要关闭的管理者
	 * @param timeout 等待时间
	 */
	public void shutdownAwaitTermination(ExecutorService pool, long timeout) {
		pool.shutdown();
		try {
			if (!pool.awaitTermination(timeout, TimeUnit.SECONDS)) {
				pool.shutdownNow();
				if (!pool.awaitTermination(timeout, TimeUnit.SECONDS)) {
					LOG.error("Pool did not terminate.");
				}
			}
		}
		catch (InterruptedException ie) {
			pool.shutdownNow();
			Thread.currentThread().interrupt();
		}
	}

	// 构建默认when线程池
	public ExecutorService buildWhenExecutor() {
		LiteflowConfig liteflowConfig = LiteflowConfigGetter.get();
		return buildWhenExecutor(liteflowConfig.getThreadExecutorClass());
	}

	// 构建when线程池 - 支持多个when公用一个线程池
	public ExecutorService buildWhenExecutor(String clazz) {
		if (StrUtil.isBlank(clazz)) {
			return buildWhenExecutor();
		}
		return getExecutorService(clazz);
	}

	// 构建when线程池 - clazz和condition的hash值共同作为缓存key
	public ExecutorService buildWhenExecutorWithHash(String conditionHash) {
		LiteflowConfig liteflowConfig = LiteflowConfigGetter.get();
		return buildWhenExecutorWithHash(liteflowConfig.getThreadExecutorClass(), conditionHash);
	}

	// 构建when线程池 - clazz和condition的hash值共同作为缓存key
	public ExecutorService buildWhenExecutorWithHash(String clazz, String conditionHash) {
		if (StrUtil.isBlank(clazz)) {
			return buildWhenExecutorWithHash(conditionHash);
		}
		return getExecutorService(clazz, conditionHash);
	}

	// 构建默认的FlowExecutor线程池，用于execute2Future方法
	public ExecutorService buildMainExecutor() {
		LiteflowConfig liteflowConfig = LiteflowConfigGetter.get();
		return buildMainExecutor(liteflowConfig.getMainExecutorClass());
	}

	public ExecutorService buildMainExecutor(String clazz) {
		if (StrUtil.isBlank(clazz)) {
			return buildMainExecutor();
		}
		return getExecutorService(clazz);
	}

	//构造并行循环的线程池
	public ExecutorService buildLoopParallelExecutor(){
		LiteflowConfig liteflowConfig = LiteflowConfigGetter.get();
		return getExecutorService(liteflowConfig.getParallelLoopExecutorClass());
	}

	private ExecutorService getExecutorService(String clazz){
		return getExecutorService(clazz, null);
	}

	/**
	 * 根据线程执行构建者Class类名获取ExecutorService实例
	 */
	private ExecutorService getExecutorService(String clazz, String conditionHash) {<FILL_FUNCTION_BODY>

		try {
			String key;
			if (StrUtil.isBlank(conditionHash)){
				key = clazz;
			}else{
				key = StrUtil.format("{}_{}", clazz, conditionHash);
			}

			ExecutorService executorServiceFromCache = executorServiceMap.get(key);
			if (ObjectUtil.isNotNull(executorServiceFromCache)) {
				return executorServiceFromCache;
			}
			else {
				Class<ExecutorBuilder> executorClass = (Class<ExecutorBuilder>) Class.forName(clazz);
				ExecutorBuilder executorBuilder = ContextAwareHolder.loadContextAware().registerBean(executorClass);
				ExecutorService executorService = executorBuilder.buildExecutor();
				executorServiceMap.put(key, executorService);
				return executorService;
			}
		}
		catch (Exception e) {
			LOG.error(e.getMessage());
			throw new ThreadExecutorServiceCreateException(e.getMessage());
		}
	
<no_super_class>