Top Description Constructors Methods
com.google.common.util.concurrent

public final Class Callables

extends Object
Class Inheritance
Annotations
@GwtCompatible
emulated:true
@ElementTypesAreNonnullByDefault
Static Imports
com.google.common.base.Preconditions.checkNotNull

Static utility methods pertaining to the Callable interface.
Author
Isaac Shum
Since
1.0

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public static <T extends @Nullable Object> AsyncCallable<T>
asAsyncCallable(Callable<T> callable, ListeningExecutorService listeningExecutorService)

Creates an AsyncCallable from a Callable.

public static <T extends @Nullable Object> Callable<T>
returning(T value)

Creates a Callable which immediately returns a preset value each time it is called.

pack-priv static <T extends @Nullable Object> Callable<T>
threadRenaming(Callable<T>
The callable to wrap
callable
,
Supplier<String>
The supplier of thread names, get will be called once for each invocation of the wrapped callable.
nameSupplier
)

Wraps the given callable such that for the duration of Callable#call the thread that is running will have the given name.

pack-priv static Runnable
threadRenaming(Runnable
The Runnable to wrap
task
,
Supplier<String>
The supplier of thread names, get will be called once for each invocation of the wrapped callable.
nameSupplier
)

Wraps the given runnable such that for the duration of Runnable#run the thread that is running with have the given name.

private static boolean
trySetName(String threadName, Thread currentThread)

Tries to set name of the given Thread, returns true if successful.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Constructor Detail

Callablesback to summary
private Callables()

Method Detail

asAsyncCallableback to summary
public static <T extends @Nullable Object> AsyncCallable<T> asAsyncCallable(Callable<T> callable, ListeningExecutorService listeningExecutorService)

Creates an AsyncCallable from a Callable.

The AsyncCallable returns the ListenableFuture resulting from ListeningExecutorService#submit(Callable).

Annotations
@J2ktIncompatible
@GwtIncompatible
Since
20.0
returningback to summary
public static <T extends @Nullable Object> Callable<T> returning(T value)

Creates a Callable which immediately returns a preset value each time it is called.

threadRenamingback to summary
pack-priv static <T extends @Nullable Object> Callable<T> threadRenaming(Callable<T> callable, Supplier<String> nameSupplier)

Wraps the given callable such that for the duration of Callable#call the thread that is running will have the given name.

Parameters
callable:Callable<T>

The callable to wrap

nameSupplier:Supplier<String>

The supplier of thread names, get will be called once for each invocation of the wrapped callable.

Annotations
@J2ktIncompatible
@GwtIncompatible
threadRenamingback to summary
pack-priv static Runnable threadRenaming(Runnable task, Supplier<String> nameSupplier)

Wraps the given runnable such that for the duration of Runnable#run the thread that is running with have the given name.

Parameters
task:Runnable

The Runnable to wrap

nameSupplier:Supplier<String>

The supplier of thread names, get will be called once for each invocation of the wrapped callable.

Annotations
@J2ktIncompatible
@GwtIncompatible
trySetNameback to summary
private static boolean trySetName(String threadName, Thread currentThread)

Tries to set name of the given Thread, returns true if successful.

Annotations
@J2ktIncompatible
@GwtIncompatible