Interface ThreadContextExecutorService

All Superinterfaces:
Executor, ExecutorService
All Known Implementing Classes:
DefaultThreadContextExecutorService

public interface ThreadContextExecutorService extends ExecutorService
Allows the execution of Runnable and Callable within a ThreadContext within a ExecutorService.

The ThreadContext properties will be automatically propagated to the asynchronous task (either Runnable or Callable) if the current Thread already contains a ThreadContext.

For example:

 final DefaultThreadContextExecutorService executor =
     DefaultThreadContextExecutorService.of(Executors.newCachedThreadPool());
 final Future<Try<Tenant>> tenant =
     executor.submit(
         // code that is executed within the ThreadContext created by DefaultThreadContextExecutorService
         TenantAccessor::tryGetCurrentTenant);
 
 
See Also: