java从心学习-嘿嘿
/** * A task that returns a result and may throw an exception. * Implementors define a single method with no arguments called * {@code call}. * *The {
@code Callable} interface is similar to {@link * java.lang.Runnable}, in that both are designed for classes whose * instances are potentially executed by another thread. A * {@code Runnable}, however, does not return a result and cannot * throw a checked exception. * *The {
@link Executors} class contains utility methods to * convert from other common forms to {@code Callable} classes. * * @see Executor * @since 1.5 * @author Doug Lea * @paramthe result type of method { @code call} */ @FunctionalInterface public interface Callable{ /** * Computes a result, or throws an exception if unable to do so. * * @return computed result * @throws Exception if unable to compute a result */ V call() throws Exception; }
可能会抛出异常和返回结果的线程类。和runnable接口相似,不同的是runnable接口不会返回接口也不会抛出异常。