Hacker News new | past | comments | ask | show | jobs | submit login

I don't know who owns the term "futures", but the limitations of javascript promises are just choices that javascript made.

In Java, you can write:

    List<Future<String>> futures = new ArrayList<>();
    ...loop that populates futures
    List<String> strings = futures.stream().map(Future::get);
The loop will run a series of futures (potentially asynchronously...the use of a Future is decoupled from the actual choice of thread pool, etc). The map will collect the results in a blocking fashion. And Future.get() will rethrow any errors that were uncaught in the execution.



Join us for AI Startup School this June 16-17 in San Francisco!

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: