jaroslav@601: /* jaroslav@601: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. jaroslav@601: * jaroslav@601: * This code is free software; you can redistribute it and/or modify it jaroslav@601: * under the terms of the GNU General Public License version 2 only, as jaroslav@601: * published by the Free Software Foundation. Oracle designates this jaroslav@601: * particular file as subject to the "Classpath" exception as provided jaroslav@601: * by Oracle in the LICENSE file that accompanied this code. jaroslav@601: * jaroslav@601: * This code is distributed in the hope that it will be useful, but WITHOUT jaroslav@601: * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or jaroslav@601: * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License jaroslav@601: * version 2 for more details (a copy is included in the LICENSE file that jaroslav@601: * accompanied this code). jaroslav@601: * jaroslav@601: * You should have received a copy of the GNU General Public License version jaroslav@601: * 2 along with this work; if not, write to the Free Software Foundation, jaroslav@601: * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. jaroslav@601: * jaroslav@601: * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA jaroslav@601: * or visit www.oracle.com if you need additional information or have any jaroslav@601: * questions. jaroslav@601: */ jaroslav@601: jaroslav@601: /* jaroslav@601: * This file is available under and governed by the GNU General Public jaroslav@601: * License version 2 only, as published by the Free Software Foundation. jaroslav@601: * However, the following notice accompanied the original version of this jaroslav@601: * file: jaroslav@601: * jaroslav@601: * Written by Doug Lea with assistance from members of JCP JSR-166 jaroslav@601: * Expert Group and released to the public domain, as explained at jaroslav@601: * http://creativecommons.org/publicdomain/zero/1.0/ jaroslav@601: */ jaroslav@601: jaroslav@601: package java.util.concurrent; jaroslav@601: jaroslav@601: /** jaroslav@601: * A task that returns a result and may throw an exception. jaroslav@601: * Implementors define a single method with no arguments called jaroslav@601: * call. jaroslav@601: * jaroslav@601: *

The Callable interface is similar to {@link jaroslav@601: * java.lang.Runnable}, in that both are designed for classes whose jaroslav@601: * instances are potentially executed by another thread. A jaroslav@601: * Runnable, however, does not return a result and cannot jaroslav@601: * throw a checked exception. jaroslav@601: * jaroslav@601: *

The {@link Executors} class contains utility methods to jaroslav@601: * convert from other common forms to Callable classes. jaroslav@601: * jaroslav@601: * @see Executor jaroslav@601: * @since 1.5 jaroslav@601: * @author Doug Lea jaroslav@601: * @param the result type of method call jaroslav@601: */ jaroslav@601: public interface Callable { jaroslav@601: /** jaroslav@601: * Computes a result, or throws an exception if unable to do so. jaroslav@601: * jaroslav@601: * @return computed result jaroslav@601: * @throws Exception if unable to compute a result jaroslav@601: */ jaroslav@601: V call() throws Exception; jaroslav@601: }