package com.uas.account.core.util;

import java.util.Collection;
import java.util.List;

import com.uas.account.core.ICallable;
import com.uas.account.core.MergeTask;

public class ExecuteUtils {

	public static void asyncExecute(Runnable runnable) {
		new Thread(runnable).start();
	}

	/**
	 * 多任务异步执行，结果以list返回
	 * 
	 * @param callable
	 * @param arguments
	 * @return
	 */
	public static <V, T> List<V> execute(ICallable<V, T> callable, Collection<T> arguments) {
		MergeTask<V, T> task = new MergeTask<V, T>(callable);
		for (T arg : arguments) {
			task.join(arg);
		}
		return task.execute();
	}

}
