Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse Collections » Interpreting multiple asParallel() calls
Interpreting multiple asParallel() calls [message #1823506] Fri, 27 March 2020 18:02 Go to next message
Simon Vrouwenvelder is currently offline Simon VrouwenvelderFriend
Messages: 1
Registered: March 2020
Junior Member
From https://github.com/eclipse/eclipse-collections/blob/master/docs/guide.md one can read:

Quote:
"It often makes sense to share thread pools between multiple calls to asParallel."


As far as I read this, it is possible to divide the work with more calls to asParallel() within the same expression. For Example, assume that myList has 3 items, and that mySecondList has 2. Then with the following code (batchsize of 1 troughout) all the computations of p.Compute() will be parallelized with 3*2 = 6 treads.

myOutput =myList.asParallel(executor, 1).flatCollect(myItem-> mySecondList.asParallel(executor,1)
                .flatCollect(p -> p.Compute(myItem));


Is this interpretation correct?
Re: Interpreting multiple asParallel() calls [message #1827860 is a reply to message #1823506] Mon, 25 May 2020 19:01 Go to previous message
Donald Raab is currently offline Donald RaabFriend
Messages: 12
Registered: March 2016
Junior Member
Hi Simon,

The total number of threads should be determined by the executor that you are passing in to both calls. With a batchsize of 1, each item will be executed individually against one of the threads in the pool in the executor.

This would be a good question to ask in StackOverflow if you tag it with eclipse-collections. Craig Motlin who wrote most of the lazy parallel implementation in Eclipse Collections would be able to explain in more depth.

Craig gave a talk at QCon NY a few years ago comparing EC parallel implementation with Streams and Scala.

https://www.infoq.com/presentations/java-streams-scala-parallel-collections/

Thanks,
Don
Previous Topic:Our journey to 1000 GitHub stars and commits
Next Topic:Java Streams are great but it's time for better Java Collections
Goto Forum:
  


Current Time: Fri Apr 26 03:20:53 GMT 2024

Powered by FUDForum. Page generated in 0.03081 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top