All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.sap.cds.feature.mt.ExecutorUtils Maven / Gradle / Ivy

There is a newer version: 3.6.0
Show newest version
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