Questions tagged [parallelstream]
41 questions
0
votes
0 answers
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 using ParallelStream().
the transformImige() method…

lool
- 21
- 3
0
votes
1 answer
Why parallelStream() starts at specific point most of the times?
I have following code which prints elements of a list using parallel stream:
List l = List.of(0,1,2,3,4,5,6,7,8,9);
for (int j = 0; j < 5; j++) {
l.parallelStream().forEach(i->System.out.print(i+" "));
…

the Hutt
- 16,980
- 2
- 14
- 44
0
votes
1 answer
Can java parallel stream handle dependent tasks in a single thread
Let's say we have tasks 1-8, and we have 2 threads. Tasks 1-4 are allocated to thread 1 while tasks 5-8 are allocated to thread 2. It is possible to assign an execution sequence, for example, finish task 1 before starting task 2, task 2 will execute…

roland luo
- 1,561
- 4
- 19
- 24
0
votes
0 answers
Is the performance of 'parallelStream' function reduced by the atomic variables?
So let's say we have the following setup:
List strings = Arrays.asList( "lore ipsum ..", ... 10000 strings);
AtomicInteger count = new AtomicInteger(0);
strings.parallelStream().forEach( myString -> {
…

Edwin
- 2,146
- 20
- 26
0
votes
1 answer
How to collect a Pair in a parallelStream in Java?
Here is roughly the code that I want to change:
final List list = evaluators.parallelStream()
.map(evaluator -> evaluator.evaluate())
.flatMap(List::stream)
…

strawbee
- 11
- 3
0
votes
1 answer
Not getting ThreadContext values even after setting "isThreadContextMapInheritable" to true, using Vert.x and Log4j2
I am using Vertx and Log4j2.
This is the code for Remote.java
public class Remote extends AbstractVerticle {
@Override
public void start() throws Exception {
System.setProperty("isThreadContextMapInheritable", "true");
…
user14733140
0
votes
0 answers
Java parallelStream() IllegalArgumentException sometimes prints exception name in message
I am parsing a CSV file using parallelStream() and have noticed some odd behaviour.
The code in question is here:
public List parseAddress(List records) {
return records.subList(1, records.size())
…

Terry Sposato
- 572
- 2
- 7
-1
votes
1 answer
how to continue performing actions on next element with foreachordered on exception?
Just trying out a simple example to understand exception handling when it comes to streaming with foreachordered. Please write down suggestions on how we can continue performing actions on next element of list(20) when the current element threw…

Megha C R
- 5
- 3
-2
votes
1 answer
Java Parallel Stream Slower than Serial
I have a database record of around 1000000 paragraphs with around ~500 characters each. By reading all the records, I need to get the list of alphabet ordered by most to least used.
I mock the database reading by creating stream up to 1000000 then…

NothingBox
- 345
- 5
- 15
-2
votes
1 answer
Convert traditional for loop into Java Stream
I'm trying to convert traditional for loop into Java Stream, but some problems are occurring. Basically, my Method execution taking too much time.When I describe reducing the method execution time. When converting the traditional for loop into…

Ng Sharma
- 2,072
- 8
- 27
- 49
-3
votes
1 answer
java IntStream parallel reduce
how is a==b false when running in parallel but when used with combiner it works?
public class test {
public static int cal(final int i) {
return 1;
}
public static void main(String args[]) {
int a = IntStream.range(0, 3).reduce(0,…

Vijay Babu
- 33
- 8