Take the 2-minute tour ×

I'd like to do something like this:

(1 to 100).parallel(20).filter(_ > 20).foreach(sendViaHttp)

This means, "take a collection, create a thread pool with N threads, and run filter etc in that thread pool". My understanding of 2.8 collections (and scala in general) is sketchy. I've fiddled with CanBuildFrom, but I'm pretty certain either what I'm doing is wrong, or is just a bad idea.

Can someone help with some examples or pointers?

share|improve this question
Do you have strong restriction on 2.8? 2.9 has build-in parallel collections. –  om-nom-nom Sep 7 '11 at 21:22
Even if I could switch to 2.9, I still need control of the level of parallelism. Does 2.9 support that? –  Itai Zukerman Sep 7 '11 at 21:30
Yes, see here: stackoverflow.com/questions/5424496/… –  axel22 Sep 8 '11 at 1:45

1 Answer 1

Aggregating the comments to an acceptable answer:

If you can switch to Scala 2.9 which has build-in parallel collections

If you want to control the amount of parallel threads you can do so using the advice here.

share|improve this answer

Your Answer


