com.sap.cds.feature.mt.ExecutorUtils Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of cds-feature-mt Show documentation
Show all versions of cds-feature-mt Show documentation
Multi tenancy feature for CDS Services Java
/**************************************************************************
* (C) 2019-2024 SAP SE or an SAP affiliate company. All rights reserved. *
**************************************************************************/
package com.sap.cds.feature.mt;
import com.sap.cds.services.request.RequestContext;
import com.sap.cds.services.runtime.CdsRuntime;
import com.sap.cds.services.runtime.RequestContextRunner;
public class ExecutorUtils {
/**
* Runs the {@code runnable} asynchronously in the current {@link RequestContext}. The thread is started
* as non daemon.
* @param runnable the {@link Runnable} to execute
*/
public static void runAsynchronously(CdsRuntime runtime, Runnable runnable) {
RequestContextRunner runner = runtime.requestContext();
Thread asyncThread = new Thread(() -> {
runner.run(requestContext -> {
runnable.run();
});
});
asyncThread.setDaemon(false);
asyncThread.start();
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy