Yes, there is. You can use:
- Promise.thenApply
- Promise.handle
- Promise.thenCompose
which have a behavior similar to CompletableFuture.
To initiate an asynchronous behavior use Async class. For example, to run a function in a different thread you can write:
public String exampleFunction(String arg) { ... }
// Somewhere in the workflow code:
// Execute someFunction in a different thread.
Promise<String> f1 = Async.function(() -> someFunction("bar"));
// Handle the f1 completion asynchronously.
Promise<String> appended = f1.thenApply((r)->r + "!");
But you didn’t answer to the most important question I asked. Why are you trying to use async? It is much more complicated then synchronous code and practically never necessary while writing Temporal workflows. Have you seen this post that explains that it is OK to block workflow threads for a long time?