public class ThreadContextExecutor extends AbstractThreadContextExecutor<ThreadContextExecutor>
Callable
or Executable
within a ThreadContext
.
For example:
new ThreadContextExecutor().execute(() -> {
// code that is executed within the ThreadContext created by ThreadContextExecutor
new MyODataService().getAllEntities().top(10).execute();
});
Note: Please be aware that if you pass a ThreadContext
to the executor, you have to make
sure that this context is not destroyed during execution, for example, within asynchronous tasks. You should
therefore only pass a ThreadContext
for which you manage the lifecycle yourself.
Constructor and Description |
---|
ThreadContextExecutor() |
Modifier and Type | Method and Description |
---|---|
protected ThreadContextExecutor |
getThis()
Getter needed to allow for a type safe return in the builder methods.
|
execute, execute, getDecoratorsOrderedByPriority, getListenersOrderedByPriority, withDecorators, withDecorators, withListeners, withListeners, withoutDecorators, withoutDecorators, withoutDefaultDecorators, withoutDefaultListeners, withoutListeners, withoutListeners, withoutParentThreadContext, withThreadContext
@Nonnull protected ThreadContextExecutor getThis()
AbstractThreadContextExecutor
protected ImplementingType getThis() { return this; }in the subclasses.
getThis
in class AbstractThreadContextExecutor<ThreadContextExecutor>
Copyright © 2021 SAP SE. All rights reserved.