Question

I have two functions (f : Unit => T, g : Unit => U) for some types T, U. I want to run these two functions in parallel (equivalently on different threads). I want the main thread to wait for the two function calls to terminate and also get the result of both function calls. I was wondering what the best way to do this in Scala was. I have looked into Actors and Parallel Collections but can't find a way to do what I want. Any help would be appreciated.

Was it helpful?

Solution

You may want to look at Futures module. Its method join allows to wait for results of two concurrent computations with different types.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top