Skip to content

Tag: parallel-processing

java concurrency vs parallelism

I know the difference between the two clearly. Concurrency is performing multiple tasks alternately, while parallelism is performing multiple tasks at once. However, there is confusion in this code because a certain instructor has a different opinion than me. Here is code: I thought that running this code on multiple cores would run with parallelism, not concurrency, the instructor says

Asynchronous execution/operation with CompletableFuture in Java 8+

In Java, is calling get() method while looping on CompletableFuture instances as good as doing synchronous operations although CompletableFuture is used for async calls? Answer ‘get()’ waits until the future is completed. If that’s what you want, it’s what you use. There’s no general rule. For example, you might be using a method that is inherently asynchronous, but in your

Executor Service – InvokeAll: How to Map response?

I am working on parallel execution of 5 Tasks with Executor service, all the 5 tasks returns back with different object results-set depending upon the task. I am using executor service for parallel execution of tasks : But how do we map the result set back with the task(s) ? It may not return back the response in the same

Will using a parallel stream on a single-core processor be slower than using a sequential stream?

I am applying an operation to every element in a very large LinkedList<LinkedList<Double>>: On my computer (quad-core), parallel streams seem to be faster than using sequential streams: However, not every computer is going to be multi-core. My question is, will using parallel streams on a single-processor computer be noticeably slower than using sequential streams? Answer This is highly implementation specific,