Yes, or even better, using some abstraction that allows you to run two computations in parallel and get their results, while also properly handling errors/exceptions and interruption/cancellation. See also the notes on structured concurrency, which are about such situations.

Scala software engineer, Functional Programming enthusiast, SoftwareMill co-founder

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store