rt/emul/compact/src/main/java/java/util/concurrent/Callable.java
author Jaroslav Tulach <jaroslav.tulach@apidesign.org>
Tue, 26 Feb 2013 16:54:16 +0100
changeset 772 d382dacfd73f
parent 601 emul/compact/src/main/java/java/util/concurrent/Callable.java@5198affdb915
child 1891 c8af252ea9eb
permissions -rw-r--r--
Moving modules around so the runtime is under one master pom and can be built without building other modules that are in the repository
jaroslav@601
     1
/*
jaroslav@601
     2
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
jaroslav@601
     3
 *
jaroslav@601
     4
 * This code is free software; you can redistribute it and/or modify it
jaroslav@601
     5
 * under the terms of the GNU General Public License version 2 only, as
jaroslav@601
     6
 * published by the Free Software Foundation.  Oracle designates this
jaroslav@601
     7
 * particular file as subject to the "Classpath" exception as provided
jaroslav@601
     8
 * by Oracle in the LICENSE file that accompanied this code.
jaroslav@601
     9
 *
jaroslav@601
    10
 * This code is distributed in the hope that it will be useful, but WITHOUT
jaroslav@601
    11
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
jaroslav@601
    12
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
jaroslav@601
    13
 * version 2 for more details (a copy is included in the LICENSE file that
jaroslav@601
    14
 * accompanied this code).
jaroslav@601
    15
 *
jaroslav@601
    16
 * You should have received a copy of the GNU General Public License version
jaroslav@601
    17
 * 2 along with this work; if not, write to the Free Software Foundation,
jaroslav@601
    18
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
jaroslav@601
    19
 *
jaroslav@601
    20
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
jaroslav@601
    21
 * or visit www.oracle.com if you need additional information or have any
jaroslav@601
    22
 * questions.
jaroslav@601
    23
 */
jaroslav@601
    24
jaroslav@601
    25
/*
jaroslav@601
    26
 * This file is available under and governed by the GNU General Public
jaroslav@601
    27
 * License version 2 only, as published by the Free Software Foundation.
jaroslav@601
    28
 * However, the following notice accompanied the original version of this
jaroslav@601
    29
 * file:
jaroslav@601
    30
 *
jaroslav@601
    31
 * Written by Doug Lea with assistance from members of JCP JSR-166
jaroslav@601
    32
 * Expert Group and released to the public domain, as explained at
jaroslav@601
    33
 * http://creativecommons.org/publicdomain/zero/1.0/
jaroslav@601
    34
 */
jaroslav@601
    35
jaroslav@601
    36
package java.util.concurrent;
jaroslav@601
    37
jaroslav@601
    38
/**
jaroslav@601
    39
 * A task that returns a result and may throw an exception.
jaroslav@601
    40
 * Implementors define a single method with no arguments called
jaroslav@601
    41
 * <tt>call</tt>.
jaroslav@601
    42
 *
jaroslav@601
    43
 * <p>The <tt>Callable</tt> interface is similar to {@link
jaroslav@601
    44
 * java.lang.Runnable}, in that both are designed for classes whose
jaroslav@601
    45
 * instances are potentially executed by another thread.  A
jaroslav@601
    46
 * <tt>Runnable</tt>, however, does not return a result and cannot
jaroslav@601
    47
 * throw a checked exception.
jaroslav@601
    48
 *
jaroslav@601
    49
 * <p> The {@link Executors} class contains utility methods to
jaroslav@601
    50
 * convert from other common forms to <tt>Callable</tt> classes.
jaroslav@601
    51
 *
jaroslav@601
    52
 * @see Executor
jaroslav@601
    53
 * @since 1.5
jaroslav@601
    54
 * @author Doug Lea
jaroslav@601
    55
 * @param <V> the result type of method <tt>call</tt>
jaroslav@601
    56
 */
jaroslav@601
    57
public interface Callable<V> {
jaroslav@601
    58
    /**
jaroslav@601
    59
     * Computes a result, or throws an exception if unable to do so.
jaroslav@601
    60
     *
jaroslav@601
    61
     * @return computed result
jaroslav@601
    62
     * @throws Exception if unable to compute a result
jaroslav@601
    63
     */
jaroslav@601
    64
    V call() throws Exception;
jaroslav@601
    65
}