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

thenAccept (Future method)

Last update:
Jun 9, 2026
After this Future succeeds, runs a consuming action on the completing thread.

Description

Same behavior as thenAcceptAsync, except the action runs synchronously on the completing thread.

Returns

A new Future.

Category

Asynchronous programming

Function syntax

future.thenAccept(action)

Parameters

ParameterDescription
actionRequired. A function that takes the previous result and performs an action (void return).

See also

Example

Use the same pattern as async; for sync-only samples see thenAcceptBoth tests that pair two futures.
future = runAsync(function() { return "test"; });
future.thenAccept(function(x) { variables.consumed = x; }).get();
writeOutput(variables.consumed); // test

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