Stay organized with collections
Save and categorize content based on your preferences.
Callable
@FunctionalInterface interface Callable<V : Any!>
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 , 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 |
Computes a result, or throws an exception if unable to do so.
|
Public methods
call
abstract fun call(): V
Computes a result, or throws an exception if unable to do so.
Exceptions |
java.lang.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](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)\n\nCallable\n========\n\n```\n@FunctionalInterface interface Callable\u003cV : Any!\u003e\n```\n\n|------------------------------------|\n| [java.util.concurrent.Callable](#) |\n\nA task that returns a result and may throw an exception. Implementors define a single method with no arguments called `call`.\n\nThe `Callable` interface is similar to , 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.\n\nThe [Executors](/reference/kotlin/java/util/concurrent/Executors) class contains utility methods to convert from other common forms to `Callable` classes.\n\nSummary\n-------\n\n| Public methods ||\n|------------|-----------------------------------------------------------------------------------|\n| abstract V | [call](#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](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels) \n\n```\nabstract fun call(): V\n```\n\nComputes a result, or throws an exception if unable to do so.\n\n| Return ||\n|---|-----------------|\n| V | computed result |\n\n| Exceptions ||\n|-----------------------|-------------------------------|\n| `java.lang.Exception` | if unable to compute a result |"]]