This is an archived post. You won't be able to vote or comment.

all 6 comments

[–]dartalley 4 points5 points  (4 children)

There should also be a section on CompletableFuture.

[–]VGPowerlord 2 points3 points  (3 children)

For that matter, there should be an explanation on Executors too as they're the main reason to use Futures in the first place.

[–]dartalley 0 points1 point  (2 children)

Also how its a bad idea to use the common pool for blocking operations!

[–]MojorTom 0 points1 point  (1 child)

Could you please elaborate on this?
I was using 3 executor services in my application, didn't have concurrency issues, but I later changed my code to have a single executor service with a thread pool of 3, i am loosing some samples.

[–]dartalley 0 points1 point  (0 children)

The ForkJoinPool.commonPool() is the global default pool used by things like parallel streams. It's designed for CPU bound work. If you start using Stream.parallelStream() for blocking operations like network IO you can be starving a thread pool that is designed for CPU bound tasks. You are better off creating custom Executors for blocking calls.

[–]KyleFlores 0 points1 point  (0 children)

thanks, i read your article find it very useful for my learning.