Class DefaultThreadContextExecutorService
java.lang.Object
com.sap.cloud.sdk.cloudplatform.thread.DefaultThreadContextExecutorService
- All Implemented Interfaces:
ThreadContextExecutorService
,Executor
,ExecutorService
public final class DefaultThreadContextExecutorService
extends Object
implements ThreadContextExecutorService
This class represents the default implementation of
ThreadContextExecutorService
.-
Method Summary
Modifier and TypeMethodDescriptionboolean
awaitTermination
(long timeout, TimeUnit unit) void
void
execute
(Runnable command, ThreadContext threadContext) Attach aThreadContext
to the given command and execute it.void
execute
(Runnable command, ThreadContextExecutor threadContextExecutor) Attach aThreadContextExecutor
to the given command and execute it.invokeAll
(Collection<? extends Callable<T>> tasks) invokeAll
(Collection<? extends Callable<T>> tasks, long timeout, TimeUnit unit) <T> T
invokeAny
(Collection<? extends Callable<T>> tasks) <T> T
invokeAny
(Collection<? extends Callable<T>> tasks, long timeout, TimeUnit unit) boolean
boolean
of
(ExecutorService executorService) Static factory method that enables the givenExecutorService
to attach aThreadContext
to its tasks.void
shutdown()
Future<?>
Future<?>
submit
(Runnable task, ThreadContext threadContext) Attach aThreadContext
to the given task and execute it.Future<?>
submit
(Runnable task, ThreadContextExecutor threadContextExecutor) Attach aThreadContextExecutor
to the given task and execute it.<T> Future<T>
<T> Future<T>
submit
(Runnable task, T result, ThreadContext threadContext) Attach aThreadContext
to the given task and execute it.<T> Future<T>
submit
(Runnable task, T result, ThreadContextExecutor threadContextExecutor) Attach aThreadContextExecutor
to the given task and execute it.<T> Future<T>
<T> Future<T>
submit
(Callable<T> task, ThreadContext threadContext) Attach aThreadContext
to the given task and execute it.<T> Future<T>
submit
(Callable<T> task, ThreadContextExecutor threadContextExecutor) Attach aThreadContextExecutor
to the given task and execute it.
-
Method Details
-
of
@Nonnull public static DefaultThreadContextExecutorService of(@Nonnull ExecutorService executorService) Static factory method that enables the givenExecutorService
to attach aThreadContext
to its tasks. The properties will be inherited only if the current parentThread
contains aThreadContext
.- Parameters:
executorService
- The executor service instance.- Returns:
- The customized executor service.
-
execute
-
execute
Description copied from interface:ThreadContextExecutorService
Attach aThreadContext
to the given command and execute it.- Specified by:
execute
in interfaceThreadContextExecutorService
- Parameters:
command
- the runnable taskthreadContext
- theThreadContext
to attach to the command- See Also:
-
execute
public void execute(@Nonnull Runnable command, @Nonnull ThreadContextExecutor threadContextExecutor) Description copied from interface:ThreadContextExecutorService
Attach aThreadContextExecutor
to the given command and execute it.- Specified by:
execute
in interfaceThreadContextExecutorService
- Parameters:
command
- the runnable taskthreadContextExecutor
- theThreadContextExecutor
to attach to the command- See Also:
-
shutdown
public void shutdown()- Specified by:
shutdown
in interfaceExecutorService
-
shutdownNow
- Specified by:
shutdownNow
in interfaceExecutorService
-
isShutdown
public boolean isShutdown()- Specified by:
isShutdown
in interfaceExecutorService
-
isTerminated
public boolean isTerminated()- Specified by:
isTerminated
in interfaceExecutorService
-
awaitTermination
- Specified by:
awaitTermination
in interfaceExecutorService
- Throws:
InterruptedException
-
submit
- Specified by:
submit
in interfaceExecutorService
-
submit
@Nonnull public <T> Future<T> submit(@Nonnull Callable<T> task, @Nonnull ThreadContext threadContext) Description copied from interface:ThreadContextExecutorService
Attach aThreadContext
to the given task and execute it.- Specified by:
submit
in interfaceThreadContextExecutorService
- Type Parameters:
T
- the type of the task's result- Parameters:
task
- the task to submitthreadContext
- theThreadContext
to attach to the task- Returns:
- a Future representing pending completion of the task
- See Also:
-
submit
@Nonnull public <T> Future<T> submit(@Nonnull Callable<T> task, @Nonnull ThreadContextExecutor threadContextExecutor) Description copied from interface:ThreadContextExecutorService
Attach aThreadContextExecutor
to the given task and execute it.- Specified by:
submit
in interfaceThreadContextExecutorService
- Type Parameters:
T
- the type of the task's result- Parameters:
task
- the task to submitthreadContextExecutor
- theThreadContextExecutor
to attach to the task- Returns:
- a Future representing pending completion of the task
- See Also:
-
submit
- Specified by:
submit
in interfaceExecutorService
-
submit
@Nonnull public <T> Future<T> submit(@Nonnull Runnable task, @Nonnull T result, @Nonnull ThreadContext threadContext) Description copied from interface:ThreadContextExecutorService
Attach aThreadContext
to the given task and execute it.- Specified by:
submit
in interfaceThreadContextExecutorService
- Type Parameters:
T
- the type of the task's result- Parameters:
task
- the task to submitresult
- the result to returnthreadContext
- theThreadContext
to attach to the task- Returns:
- a Future representing pending completion of the task
- See Also:
-
submit
@Nonnull public <T> Future<T> submit(@Nonnull Runnable task, @Nonnull T result, @Nonnull ThreadContextExecutor threadContextExecutor) Description copied from interface:ThreadContextExecutorService
Attach aThreadContextExecutor
to the given task and execute it.- Specified by:
submit
in interfaceThreadContextExecutorService
- Type Parameters:
T
- the type of the task's result- Parameters:
task
- the task to submitresult
- the result to returnthreadContextExecutor
- theThreadContextExecutor
to attach to the task- Returns:
- a Future representing pending completion of the task
- See Also:
-
submit
- Specified by:
submit
in interfaceExecutorService
-
submit
Description copied from interface:ThreadContextExecutorService
Attach aThreadContext
to the given task and execute it.- Specified by:
submit
in interfaceThreadContextExecutorService
- Parameters:
task
- the task to submitthreadContext
- theThreadContext
to attach to the task- Returns:
- a Future representing pending completion of the task
- See Also:
-
submit
@Nonnull public Future<?> submit(@Nonnull Runnable task, @Nonnull ThreadContextExecutor threadContextExecutor) Description copied from interface:ThreadContextExecutorService
Attach aThreadContextExecutor
to the given task and execute it.- Specified by:
submit
in interfaceThreadContextExecutorService
- Parameters:
task
- the task to submitthreadContextExecutor
- theThreadContextExecutor
to attach to the task- Returns:
- a Future representing pending completion of the task
- See Also:
-
invokeAll
@Nonnull public <T> List<Future<T>> invokeAll(@Nonnull Collection<? extends Callable<T>> tasks) throws InterruptedException - Specified by:
invokeAll
in interfaceExecutorService
- Throws:
InterruptedException
-
invokeAll
@Nonnull public <T> List<Future<T>> invokeAll(@Nonnull Collection<? extends Callable<T>> tasks, long timeout, @Nonnull TimeUnit unit) throws InterruptedException - Specified by:
invokeAll
in interfaceExecutorService
- Throws:
InterruptedException
-
invokeAny
@Nonnull public <T> T invokeAny(@Nonnull Collection<? extends Callable<T>> tasks) throws InterruptedException, ExecutionException - Specified by:
invokeAny
in interfaceExecutorService
- Throws:
InterruptedException
ExecutionException
-
invokeAny
@Nonnull public <T> T invokeAny(@Nonnull Collection<? extends Callable<T>> tasks, long timeout, @Nonnull TimeUnit unit) throws InterruptedException, ExecutionException, TimeoutException - Specified by:
invokeAny
in interfaceExecutorService
- Throws:
InterruptedException
ExecutionException
TimeoutException
-