Stay organized with collections
Save and categorize content based on your preferences.
Callable
public
interface
Callable
java.util.concurrent.Callable<V>
|
A task that returns a result and may throw an exception.
Implementors define a single method with no arguments called
call
.
The Callable
interface is similar to Runnable
, in that both are designed for classes whose
instances are potentially executed by another thread. A
Runnable
, however, does not return a result and cannot
throw a checked exception.
The Executors
class contains utility methods to
convert from other common forms to Callable
classes.
Summary
Public methods |
abstract
V
|
call()
Computes a result, or throws an exception if unable to do so.
|
Public methods
call
public abstract V call ()
Computes a result, or throws an exception if unable to do so.
Returns |
V |
computed result |
Throws |
Exception |
if unable to compute a result |
Content and code samples on this page are subject to the licenses described in the Content License. Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.
Last updated 2025-02-10 UTC.
[null,null,["Last updated 2025-02-10 UTC."],[],[],null,["# Callable\n\nAdded in [API level 1](/guide/topics/manifest/uses-sdk-element#ApiLevels) \n\nCallable\n========\n\n\n`\npublic\n\n\ninterface\nCallable\n`\n\n\n`\n\n\n`\n\n|------------------------------------|\n| java.util.concurrent.Callable\\\u003cV\\\u003e |\n\n\u003cbr /\u003e\n\n*** ** * ** ***\n\nA task that returns a result and may throw an exception.\nImplementors define a single method with no arguments called\n`call`.\n\nThe `Callable` interface is similar to [Runnable](/reference/java/lang/Runnable), in that both are designed for classes whose\ninstances are potentially executed by another thread. A\n`Runnable`, however, does not return a result and cannot\nthrow a checked exception.\n\nThe [Executors](/reference/java/util/concurrent/Executors) class contains utility methods to\nconvert from other common forms to `Callable` classes. \n**See also:**\n\n- [Executor](/reference/java/util/concurrent/Executor)\n\nSummary\n-------\n\n| ### Public methods ||\n|---------------|-------------------------------------------------------------------------------------------------------------------------------|\n| ` abstract V` | ` `[call](/reference/java/util/concurrent/Callable#call())`() ` Computes a result, or throws an exception if unable to do so. |\n\nPublic methods\n--------------\n\n### call\n\nAdded in [API level 1](/guide/topics/manifest/uses-sdk-element#ApiLevels) \n\n```\npublic abstract V call ()\n```\n\nComputes a result, or throws an exception if unable to do so.\n\n\u003cbr /\u003e\n\n| Returns ||\n|-----|------------------------|\n| `V` | computed result \u003cbr /\u003e |\n\n| Throws ||\n|---------------------------------------------|-------------------------------|\n| [Exception](/reference/java/lang/Exception) | if unable to compute a result |"]]