Class ThreadContextExecutor

java.lang.Object
com.sap.cloud.sdk.cloudplatform.thread.ThreadContextExecutor

public final class ThreadContextExecutor extends Object
Executes a Callable or Executable within a ThreadContext.

For example:

 ThreadContextExecutor.fromNewContext().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.