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 TypeMethodDescriptionbooleanawaitTermination(long timeout, TimeUnit unit) voidvoidexecute(Runnable command, ThreadContext threadContext) Attach aThreadContextto the given command and execute it.voidexecute(Runnable command, ThreadContextExecutor threadContextExecutor) Attach aThreadContextExecutorto the given command and execute it.invokeAll(Collection<? extends Callable<T>> tasks) invokeAll(Collection<? extends Callable<T>> tasks, long timeout, TimeUnit unit) <T> TinvokeAny(Collection<? extends Callable<T>> tasks) <T> TinvokeAny(Collection<? extends Callable<T>> tasks, long timeout, TimeUnit unit) booleanbooleanof(ExecutorService executorService) Static factory method that enables the givenExecutorServiceto attach aThreadContextto its tasks.voidshutdown()Future<?>Future<?>submit(Runnable task, ThreadContext threadContext) Attach aThreadContextto the given task and execute it.Future<?>submit(Runnable task, ThreadContextExecutor threadContextExecutor) Attach aThreadContextExecutorto the given task and execute it.<T> Future<T><T> Future<T>submit(Runnable task, T result, ThreadContext threadContext) Attach aThreadContextto the given task and execute it.<T> Future<T>submit(Runnable task, T result, ThreadContextExecutor threadContextExecutor) Attach aThreadContextExecutorto the given task and execute it.<T> Future<T><T> Future<T>submit(Callable<T> task, ThreadContext threadContext) Attach aThreadContextto the given task and execute it.<T> Future<T>submit(Callable<T> task, ThreadContextExecutor threadContextExecutor) Attach aThreadContextExecutorto the given task and execute it.
-
Method Details
-
of
@Nonnull public static DefaultThreadContextExecutorService of(@Nonnull ExecutorService executorService) Static factory method that enables the givenExecutorServiceto attach aThreadContextto its tasks. The properties will be inherited only if the current parentThreadcontains aThreadContext.- Parameters:
executorService- The executor service instance.- Returns:
- The customized executor service.
-
execute
-
execute
Description copied from interface:ThreadContextExecutorServiceAttach aThreadContextto the given command and execute it.- Specified by:
executein interfaceThreadContextExecutorService- Parameters:
command- the runnable taskthreadContext- theThreadContextto attach to the command- See Also:
-
execute
public void execute(@Nonnull Runnable command, @Nonnull ThreadContextExecutor threadContextExecutor) Description copied from interface:ThreadContextExecutorServiceAttach aThreadContextExecutorto the given command and execute it.- Specified by:
executein interfaceThreadContextExecutorService- Parameters:
command- the runnable taskthreadContextExecutor- theThreadContextExecutorto attach to the command- See Also:
-
shutdown
public void shutdown()- Specified by:
shutdownin interfaceExecutorService
-
shutdownNow
- Specified by:
shutdownNowin interfaceExecutorService
-
isShutdown
public boolean isShutdown()- Specified by:
isShutdownin interfaceExecutorService
-
isTerminated
public boolean isTerminated()- Specified by:
isTerminatedin interfaceExecutorService
-
awaitTermination
- Specified by:
awaitTerminationin interfaceExecutorService- Throws:
InterruptedException
-
submit
- Specified by:
submitin interfaceExecutorService
-
submit
@Nonnull public <T> Future<T> submit(@Nonnull Callable<T> task, @Nonnull ThreadContext threadContext) Description copied from interface:ThreadContextExecutorServiceAttach aThreadContextto the given task and execute it.- Specified by:
submitin interfaceThreadContextExecutorService- Type Parameters:
T- the type of the task's result- Parameters:
task- the task to submitthreadContext- theThreadContextto 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:ThreadContextExecutorServiceAttach aThreadContextExecutorto the given task and execute it.- Specified by:
submitin interfaceThreadContextExecutorService- Type Parameters:
T- the type of the task's result- Parameters:
task- the task to submitthreadContextExecutor- theThreadContextExecutorto attach to the task- Returns:
- a Future representing pending completion of the task
- See Also:
-
submit
- Specified by:
submitin interfaceExecutorService
-
submit
@Nonnull public <T> Future<T> submit(@Nonnull Runnable task, @Nonnull T result, @Nonnull ThreadContext threadContext) Description copied from interface:ThreadContextExecutorServiceAttach aThreadContextto the given task and execute it.- Specified by:
submitin interfaceThreadContextExecutorService- Type Parameters:
T- the type of the task's result- Parameters:
task- the task to submitresult- the result to returnthreadContext- theThreadContextto 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:ThreadContextExecutorServiceAttach aThreadContextExecutorto the given task and execute it.- Specified by:
submitin interfaceThreadContextExecutorService- Type Parameters:
T- the type of the task's result- Parameters:
task- the task to submitresult- the result to returnthreadContextExecutor- theThreadContextExecutorto attach to the task- Returns:
- a Future representing pending completion of the task
- See Also:
-
submit
- Specified by:
submitin interfaceExecutorService
-
submit
Description copied from interface:ThreadContextExecutorServiceAttach aThreadContextto the given task and execute it.- Specified by:
submitin interfaceThreadContextExecutorService- Parameters:
task- the task to submitthreadContext- theThreadContextto 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:ThreadContextExecutorServiceAttach aThreadContextExecutorto the given task and execute it.- Specified by:
submitin interfaceThreadContextExecutorService- Parameters:
task- the task to submitthreadContextExecutor- theThreadContextExecutorto 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:
invokeAllin 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:
invokeAllin interfaceExecutorService- Throws:
InterruptedException
-
invokeAny
@Nonnull public <T> T invokeAny(@Nonnull Collection<? extends Callable<T>> tasks) throws InterruptedException, ExecutionException - Specified by:
invokeAnyin interfaceExecutorService- Throws:
InterruptedExceptionExecutionException
-
invokeAny
@Nonnull public <T> T invokeAny(@Nonnull Collection<? extends Callable<T>> tasks, long timeout, @Nonnull TimeUnit unit) throws InterruptedException, ExecutionException, TimeoutException - Specified by:
invokeAnyin interfaceExecutorService- Throws:
InterruptedExceptionExecutionExceptionTimeoutException
-