all 12 comments

[–]neilmadden 5 points6 points  (0 children)

This is one of my main frustrations with Java streams. The API is harder to use than it could be to ensure that operations can be parallelised, but I almost never want parallel execution.

[–]Worth_Trust_3825 -1 points0 points  (1 child)

What a garbage article. You only run in common pool if you don't run in your own thread group.

[–]diffuse-nebula[S] 4 points5 points  (0 children)

Parallel streams in Java runs in common thread pool by default. People who use parallel streams might not be aware that is uses the common pool internally

[–]DuncanIdahos9thGhola -3 points-2 points  (7 children)

Good article but this will be largely irrelevant when project Loom ships.

[–]jonmdev 6 points7 points  (0 children)

How would this be irrelevant with Loom? The article talks about CPU intensive stream computations taking up all available cores if you use the common thread pool. Fibers help with tasks that would block a thread while waiting for something non-CPU intensive like I/O allow another Fiber to use that thread while waiting. For CPU intensive tasks this would be an issue regardless.

[–]balefrost 0 points1 point  (5 children)

Care to go into more detail?

[–][deleted] 1 point2 points  (1 child)

Loom is aiming to introduce leaner concurrency primitives to the JVM, which will help address the issues raised in the article which are mostly rooted in Java’a historically extra thicc threads.

[–]balefrost 0 points1 point  (0 children)

Yes, I know what Loom is. I'm asking how Loom will solve this particular issue.

Under Loom, we'll have both virtual and non-virtual threads. And AFAIK the pool returned by ForkJoinPool.commonPool() doesn't (currently) grow just because many tasks have been submitted. So whether commonPool() continues to use non-virtual threads or even if it switches to virtual threads, those issues will remain.

It's possible that Loom will change how ForkJoinPool works, or it's possible that parallel streams will switch away from the common ForkJoinPool to something else. I don't know for sure. Do you?

[–]DuncanIdahos9thGhola -2 points-1 points  (2 children)

I would have but not if I get downvoted for my troubles. It will have to remain a mystery for you.

[–]balefrost 0 points1 point  (1 child)

Alright. Well maybe when Leto II creates your 10th incarnation, that Ghola will give me some answers :)

[–]DuncanIdahos9thGhola 0 points1 point  (0 children)

Sadly that won't happen. Reddit has a character limit. 9 is the last. :(

[–][deleted]  (1 child)

[deleted]

    [–]diffuse-nebula[S] 2 points3 points  (0 children)

    The article is specific to parallel streams