Skip to main content
Filter by
Sorted by
Tagged with
3 votes
0 answers
123 views

Why are thread pools so significantly slower than parallelStream for this scenario?

This is for Java 23, but I've replicated this on Java 21 and 17 as well. I recently ran a benchmark to compare performance differences between threadpools and parallelstreams for some simple ...
Andorrax's user avatar
  • 125
1 vote
0 answers
111 views

java.util.concurrent.CompletionException: org.springframework.beans.factory.support.ScopeNotActiveException

Trying to execute below piece of code but getting an error as stated follows. Any suggestions to fix this? Source code CompletableFuture[] futures = stringList.stream().map(stringListRef -> ...
user1496783's user avatar
0 votes
1 answer
193 views

Parallelising Java 8 parallelStream independent filters

I read all the related topics on StackOverflow and other sites to understand the mechanism of the parallelStream of Java8, and to understand whether the applied filters are running concurrently or not....
NoobCoder's user avatar
  • 615
4 votes
1 answer
74 views

Unexpected behavior for the reduce() operation for the Set-backed parallel Stream

When I am reducing the Set-backed stream, the identity element appears on the right of the result: import java.util.Collection; import java.util.List; import java.util.Set; public class StreamReduce {...
Barat Sahdzijeu's user avatar
0 votes
2 answers
146 views

why parallel streams will only perform a concurrent reduction if either (not both) the stream is unordered, or the collector is UNORDERED?

I'm struggling understanding the rule mentioned in Java docs (https://docs.oracle.com/javase/8/docs/api/java/util/stream/package-summary.html) related to parallel stream stating that "The Stream....
Abdelhamid Marey's user avatar
0 votes
1 answer
99 views

Why does skip() in this parallel stream expression in Java 19 cause an OOM even with 8GB?

I get an OOM in Java 19 even with 8GB if I do this: IntStream .iterate(0, i -> i + 1) .skip(2) .limit(10_000_000) .filter(i -> checkSum(i) <= 20) .parallel() .count(); However, I don't get ...
mmirwaldt's user avatar
  • 883
0 votes
1 answer
374 views

How to throw Timeout exception for the task inside parallel stream

The code I want to achieve is as below: StreamSupport.stream(jsonArray.spliterator(), true).forEach(s ->{ try { //invoke other api and set timeout for its execution } catch(...
Usman Mohammed's user avatar
1 vote
0 answers
121 views

Why does PBEWithMD5AndDES mess up encryption in parallelStream in Java?

I am working in a Spring Boot project where we use the PBEWithMD5AndDES encryption algorithm. We use the javax.crypto.Cipher class library like the code below. When we process single requests it works ...
Hevv's user avatar
  • 41
4 votes
4 answers
3k views

Java ParallelStream: several map or single map

Introduction I'm currently developing a program in which I use Java.util.Collection.parallelStream(), and wondering if it's possible to make it more Multi-threaded. Several small map I was wondering ...
ThrowsError's user avatar
  • 1,719
0 votes
2 answers
399 views

Trying to use Map.values().parallelStream().forEach(list -> list.sort(comparator)) but get error: "Comparison method violates its general contract!"

I am trying to use multi-threading to sort arrays that are stored in a map. There are a large amount of records, ~3.1 million, and thus while I am attempting to sort these records in a single threaded ...
Sam P's user avatar
  • 11
0 votes
0 answers
1k views

LocaleContextHolder returns only language-code without country-code

I am currently using LocaleContextHolder.getLocale() to get the locale. But the issue is, sometimes it returns language-code without country-code. For e.g. : sometimes en_US, and sometimes en only ...
Vikas Gope's user avatar
0 votes
1 answer
345 views

Want to compare two Lists of records, save commons to a new list ,Records are around 1M and taking a lot of time to process

I'm processing 2 csv files and checking common entries and saving them into a new csv file .however the comparison is taking a lot of time.My approach is to first read all the data from files into ...
Danial Kayani's user avatar
2 votes
1 answer
507 views

List of Strings is not running in parallel - Java 8 parallel streams

I got a requirement to run a collection using parallel stream and it is always running in sequence, here in the below example List is always running in sequence where as IntStream is running in ...
Varma's user avatar
  • 47
0 votes
0 answers
82 views

ParallelStream() and Streams()?

the method ( transformAll ) transform all the img for a person and their friends. can we do a small modification to these two methods so that the imgs can be transformed in parallel ? for example ...
lool's user avatar
  • 21
0 votes
0 answers
92 views

Why parallelStream() starts at specific point most of the times?

I have following code which prints elements of a list using parallel stream: List<Integer> l = List.of(0,1,2,3,4,5,6,7,8,9); for (int j = 0; j < 5; j++) { l.parallelStream().forEach(i->...
the Hutt's user avatar
  • 18.5k

15 30 50 per page