Async activities in workflow

Currently I am trying to execute some activities in workflow by Async.function.

        List<Promise> listOfPromise = new ArrayList();
        listOfPromise.add(Async.function(account::consume, dto).thenApply((m)->{
            saga.addCompensation(account::refund, dto);
            return null;
        // .....
        finalResult = Promise.allOf(listOfPromise.toArray(new Promise [listOfPromise.size()]));

How can I wait until all activities tasks get completed (whatever failed and successes ).

Use the loop:

        for(Promise p: listOfPromise) {
            try {
            } catch (Exception e) {
                // handle error

Oh, thanks, I found that once the get() is called, all the async activities will be fired to process.
This is exactly what I want to do.