user1413793
user1413793

Reputation: 9347

Scala - Running Two Functions in Parallel

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.

Upvotes: 1

Views: 1980

Answers (1)

Egor Kazachkov
Egor Kazachkov

Reputation: 46

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

Upvotes: 2

Related Questions