Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Java allows not blocking callers using Futures or callbacks for a long time. As well as Promises and callbacks were available in Javascript before async / await.

    var executor = Executors.newVirtualThreadPerTaskExecutor();
    ;; or, for old Java
    var executor = Executors.newSingleThreadExecutor();

    Future<Integer> f = executor.submit(someFunc);

What is relevant in the new Java VirtualThreads and Javascript async / await is the possibility to write simple synchronous code, with the performance similar to callback-based asynchronous code.


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

Search: