Here you can find the source of getFuture(ExecutorService executorService, Callable
Parameter | Description |
---|---|
executorService | ExecutorService to use to get the Future. |
callable | the callable to run in the new Future. |
RETVAL | the return type of the callable and Future. |
public static <RETVAL> Future<RETVAL> getFuture(ExecutorService executorService, Callable<RETVAL> callable)
//package com.java2s; /**/* w w w . j a v a2 s . c o m*/ * (c) Copyright 2013 WibiData, Inc. * * See the NOTICE file distributed with this work for additional * information regarding copyright ownership. * * 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. */ import java.util.concurrent.Callable; import java.util.concurrent.ExecutorService; import java.util.concurrent.Future; public class Main { /** * Get a future from a given callable. This method uses the singleton FreshenerThreadPool to run * threads responsible for carrying out the operation of the Future. * * @param executorService ExecutorService to use to get the Future. * @param callable the callable to run in the new Future. * @param <RETVAL> the return type of the callable and Future. * @return a new Future representing asynchronous execution of the given callable. */ public static <RETVAL> Future<RETVAL> getFuture(ExecutorService executorService, Callable<RETVAL> callable) { return executorService.submit(callable); } }