Frage

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.

War es hilfreich?

Lösung

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

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top