Domanda

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.

È stato utile?

Soluzione

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

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top