Whatever message this page gives is out now! Go check it out!

runAfterBothAsync (Future method)

Last update:
May 18, 2026
When this Future and another Future both succeed, runs an action with no arguments on the async executor.

Description

Use runAfterBothAsync for cleanup or coordination that does not need the individual result values, but must wait until two tasks finish.

Returns

A new Future.

Category

Asynchronous programming

Function syntax

future.runAfterBothAsync(other, action)

Parameters

ParameterDescription
otherRequired. The other Future to wait for.
actionRequired. A function with no parameters that performs an action (void return).

See also

Example

Chain runAfterBothAsync with runAfterEitherAsync (from product tests).

<cfscript>
    f1 = runAsync(function() { return 1; });
    f2 = runAsync(function() { return 2; });
    f3 = runAsync(function() {    sleep(1000);    return 3;});
    variables.executed = [];
    future = f1.runAfterBothAsync(f2, function() {    arrayAppend(variables.executed, "both");}).runAfterEitherAsync(f3, function() {    arrayAppend(variables.executed, "either");});
    future.get();writeOutput(arrayLen(variables.executed)); // 2
</cfscript>
      

Share this page

Was this page helpful?
We're glad. Tell us how this page helped.
We're sorry. Can you tell us what didn't work for you?
Thank you for your feedback. Your response will help improve this page.

On this page