255 questions
0
votes
1
answer
61
views
RejectedExecutionException when using ManagedBlocker in nested parallelStreams
This is a follow-up from this post: Why are inner parallel streams faster with new pools than with the commonPool for this scenario?
Apologies in advance for the wall of text. This is for JDK 17.
I am ...
0
votes
1
answer
78
views
Wrapping Stream.parallel() by Executor service in Java
I'm studying Java Core on course DMDEV in Udemy and YouTube. On Level 2 in lessons Concurrent I probably saw mistake in code the tutor was made. But my question to him was still without response. So ...
0
votes
2
answers
34
views
StreamEx groupruns with parallel not working as expected
We have a use case to:
Divide a stream into smaller chunks whose size is less than a
threshold value and parallelly process the chunks.
Our current implementation is like this, where counter is a ...
0
votes
0
answers
98
views
Tomcat catalina.policy file provides security policies to JVM in JDK 21 where Security Manager is deprecated
I have the following JAVA 21 code running within a Tomcat 9 Server where a method is invoked using a CompletableFuture:
CompletableFuture.supplyAsync(this::makeHttpCall);
The method makeHttpCall ...
-1
votes
1
answer
181
views
Can I configure parallelism of ForkJoinPool created for Tomcat in Spring Boot application?
Investigating the issue Spring Boot application gets stuck when virtual threads are used on Java 21 I found out that having virtual threads enabled in Spring Boot application its Tomcat will create ...
1
vote
1
answer
64
views
All thread blocked in a pool while handling multiple tasklist
I have some problems while using ThreadPoolExecutor and I cannot figure it out.
I try to use two List<CompletableFuture<Void>> taskList lists to store tasks and then submit to a threadpool ...
1
vote
2
answers
886
views
Java 17 Fork join pool limit number of threads in pool
In java 17, we are seeing that a lot more threads are getting created (although not concurrently executing) as compared to older java version (java 8 in my case). While thread itself may not be a huge ...
2
votes
0
answers
227
views
How to get access to "ForkJoinPool" that schedules virtual threads
ForkJoinPool.commonPool()
returns reference to the common pool which is used for running streams. Is there a way get the reference to access the ForkJoinPool which schedules the virtual threads. ...
0
votes
0
answers
105
views
Uneven Load Distribution in Kubernetes Pods with Multithreaded Execution using fork join pool
I have a Spring Boot application where I had a CPU-intensive function performing 43 non-dependent function calls sequentially, resulting in significant execution time. To optimize performance, I ...
-1
votes
1
answer
170
views
How does completablefuture works? [closed]
Need to know the insights of the complete future task without an executor.
Here is my sample code
CompletableFuture.runAsync(() -> {
dosomething();
});
How is this task assigned to the thread? ...
0
votes
1
answer
209
views
stop ForkJoinPool executions when an exception occurs in one task
We have code that walks a tree structure and performs a task for each node.
for a leaf node, the task is executed immediately
for an inner node (= node with children), the result depends on the ...
2
votes
2
answers
173
views
Memory sharing between Threads
I have a scenario where I am confused little bit. As per my knowledge every thread has some local memory.
// 100 elements in SomeArray
ArrayList SomeArray = new ArrayList();
ForkJoinPool forkJoinPool ...
1
vote
2
answers
2k
views
Unhandled exception 'java.lang.OutOfMemoryError: unable to create native thread: possibly out of memory or process/resource limits reached
We have recently migrated a springboot application to 2.7.11 version, and while performing a load test, a nasty error raised :
"Unhandled exception 'java.lang.OutOfMemoryError: unable to create ...
0
votes
1
answer
77
views
Why ForkJoinTask.join() call rather block the thread instead of stealing the work as expected from work stealing mechanism
I have a recursive task which splits asymmetrically. Instead of splitting in halves it rather bites a pice of work it can execute and forks the rest of work. Such scenario does not get paralleled as ...
2
votes
3
answers
1k
views
ExecutorService does not run tasks in parallel
I have a recursive bulk task that I put into execution in a ForkJoinPool thread pool.
public class SomeTask extends RecursiveAction {
@Override
protected void compute() {
//Some ...
0
votes
0
answers
42
views
Could ExecutorService prevent Spring RestController from responding to REST calls?
I am trying to figure out why my Microservice A get stuck at a POST call restTemplate.postForEntity whenever that request takes longer than 10-15 minutes and never proceeds further to LOG.info.
This ...
2
votes
0
answers
183
views
Generate all partitions of a set in Parallel (java)
I have a list of millions of distinct sets (no two sets have the same values), where I have to find all partitions for every single set.
For instance the set {A, B, C} can be partitioned to the ...
2
votes
0
answers
187
views
Forkjoin vs Threadpool difference
I am bit confused how Forkjoin internally works vs Thread Pool. Below is the code snippet for the same. Both are having single parallelism. Ideally it should behave same as Thread pool and it should ...
0
votes
0
answers
38
views
How to make a forkjoinpool to compare two Arrays in Java?
So i'm having a problem because i neet to make a recursive void to get the positions of the numbers that are the same but i d'ont know how to make it recursively.
i wass wondering if it's possible to ...
1
vote
0
answers
256
views
Scala .PAR Method with ForkJoinPool
I am sure this is due to my inability to fully grasp the concept of .par under the hood, but I am seeing something a bit strange when using it along with a ForkJoinPool.
I have an ETL process that ...
4
votes
1
answer
1k
views
Why Spring use ForkPoolJoin instead of ThreadPoolTaskExecutor with @Async?
For my studies, I'm working on a Spring Boot REST API. I'm supposed to reduce the execution time of the code when it received a request. So, I thought that make the code asynchronous would be a good ...
0
votes
1
answer
82
views
The results differ with parallel summation in Java
I made class Sum extends RecursiveTask. The task is to calculate sum of 1 / a[i].
public class Sum extends RecursiveAction {
int[] items;
double result;
int min = 100000;
int from, to;
...
3
votes
1
answer
1k
views
SQS Consumption too slow even with parallalism
I am facing a challenging problem which has blown my head now by trying multiple things so I am here to ask some experts.
I have sqs consumer which gets 100k messages every 15 mins and I have a ...
0
votes
1
answer
720
views
How to properly see all threads in visualvm
I am trying to learn about heapdumps and threaddumps and in doing that created a very simple application which is using completable future :
public static void main(String[] args) throws ...
4
votes
1
answer
2k
views
Java ForkJoinPool hangs in JDK17
The following code works with JDK16 reproducibly and hangs with JDK17 reproducibly on my laptop (4/8-core) with basic command line options: "-ea". A JDK-ticket exists (https://bugs.openjdk....
4
votes
1
answer
930
views
CompletableFuture inside another CompletableFuture doesn't join with timeout
I have one completable future that just runs another completable future(that takes always about 2 seconds and timeout of 50 ms) and waits for it to complete with timeout 1 second.
The problem is ...
1
vote
1
answer
183
views
ForkJoinPool process Arraylist and return two arrays
i have a huge List<String[]> like about 500k elements
validation of it takes too long - 35-40 sec
validation looks like this
Iterator<String[]>iterator=parser.iterate(request....
0
votes
1
answer
246
views
ForkPoolTask.join() ConcurrentModificationException
I'm getting a very strange error here that I can't quite understand. As it stands I'm making a crawler program that uses ForkJoinTasks to scan for links on the page and then crawl those as well. ...
0
votes
1
answer
420
views
WatchService large number of directory (recursive)
I want to detect changes inside a directory, so I implement by using WatchService
public class DirWatcher implements Runnable {
private Path path;
private ExecutorService exe;
public ...
2
votes
1
answer
726
views
What is the disadvantage of using a ForkJoinPool when it is not needed?
Imagine a scenario where a task can be divided into sub-tasks, each of which does some long running process. Assuming that this heavy task occurs only in 5/100 requests submitted to the server. Would ...
0
votes
0
answers
29
views
Make a parallel process by modifying my original code as little as possible
I have this class:
package metodo_java8_moderno;
import java.util.ArrayList;
import java.util.List;
public class SingleThreadClass {
public List<Object> editAndAdd(List<List<Long>...
0
votes
1
answer
595
views
How to limit number of threads all concurrent methods at once
I am working on a legacy project which uses Java 8, Spring, HikariCP, and MySQL. Microservices' methods are triggered with a Kafka topic and start a reporting operation. Almost all triggered methods ...
1
vote
1
answer
216
views
Forkjoinpool VS sequential perofrmance
I am comparing sequential and parallel performance(using ForkJoinPool) of an algorithm(sum of first n numbers):
public class ForkJoinSumCalculator extends RecursiveTask<Long> {
private ...
0
votes
0
answers
67
views
ForkJoinTask:fork method execution
From Javadoc for ForkJoinTask::fork method:
Arranges to asynchronously execute this task in the pool the current
task is running in....
So when we invoke fork method on a ForkJoinTask, does it start ...
-1
votes
2
answers
493
views
Level of parallelism of ForkJoinPool.commonPool() [closed]
How do I check the number of threads created by ForkJoinPool.commonPool() in java? Is the degree of parallelism the same as the number of threads created by the commonPool()? How do we create threads ...
1
vote
0
answers
145
views
ForkJoinPool incorrect invokeAll method behavior (java)
ExecutorService have invokeAll method, and documentation say next:
Executes the given tasks, returning a list of Futures holding their
status and results when all complete or the timeout expires, ...
2
votes
1
answer
2k
views
ForkJoinPool::shutdown vs ForkJoinPool::shutdownNow after ForkJoinPool::join
Code:
final ForkJoinPool forkJoinPool = new ForkJoinPool(PARALLELISM_NUMBER);
try {
final List<Record> records = getRecrods();
List<...
0
votes
0
answers
626
views
perform one transaction for multiple threads
I have a method that persist data before calling multiple threads to perform other actions in parallel:
public List<dtos> myMethod(data)
repository.saveAll(data);
ForkJoinPool pool = new ...
0
votes
1
answer
898
views
Java8 - CompletableFuture - Running methods in async call sequentially
So I have this code block:
someMethod(SomeParameter someParameter) {
for (SomeObject: object) {
if (someObject is true) {
callSomeMethod(someParameter);
} else {
...
0
votes
3
answers
2k
views
Behaviour of Threads during blocking IO in Java ForkJoinPool
If the Thread inside the ForkJoinPool does a blocking I/O activity ( simulated below in code using Thread.sleep(10000)) , it should pick up another task which is not causing blocking IO.
However, ...
0
votes
1
answer
1k
views
How to scale? Make Rest API calls thousands times and update database
1. cron job started
2. create Entity1 and save to DB
3. Fetch transactionEntity from DB
4. using transactions as transactionIds.
for (Transaction id : transactionIds) {
a. create Entity2 ...
1
vote
1
answer
210
views
How does RecursiveAction work with Fibonacci?
How does recursion work in case of Fibonacci. The below example uses RecursiveAction which does not return any value. But still it is possible to calculate Fibonacci numbers. I mean for example in ...
0
votes
1
answer
374
views
Java Completable future thread are alive after method execute
I have written a small program to check behavior of Completable Future. I have not overridden the common pool.
I did not found any shut down method and when i print active number of thread at the end, ...
0
votes
1
answer
321
views
How to get desired output from ForkJoinPool.commonPool().submit
Please consider the below existing code segment in the project.
ForkJoinPool.commonPool().submit(() -> updateActions(a, b, c));
public void updateActions(a, b, c){
--some implementation--
}
...
1
vote
1
answer
2k
views
does join of ForkJoinPool block the current thread worker?
I'm trying to run a number of jobs concurrently using Java's ForkJoinPool. The main task (which is already running in the pool) spawns all the jobs and then does a series of joins. I was sure that a ...
1
vote
1
answer
371
views
Actors, ForkJoinPool, and ordering of messages
I need help understanding how an Actor system can use ForkJoinPool and maintain ordering guarantees.
I have been playing with Actr https://github.com/zakgof/actr which is a simple small actor system. ...
1
vote
1
answer
389
views
Whats the benefit to use wrokstealing from ForkJoin rather than just ordinary thread pool's queue?
Whats the benefit to use workstealing from ForkJoin rather than just ordinary thread pool's queue?
is the "workstealing" from ForkJoinPool better then just take tasks from the thread pool's ...
8
votes
1
answer
4k
views
Why does Java 17 throw a RejectedExecutionException when adding tasks to a ForkJoinPool?
I used Java 16 to make requests to an API over HTTP. To speed this up overall, I've loaded this onto a custom ForkJoinPool. I've compiled a reproducing example below.
Since moving to Java 17 (openjdk ...
2
votes
1
answer
1k
views
Why does a task sometimes run in the main thread although it was submitted to the common ForkJoinPool?
Can someone explain me why some tasks sometimes run in the main thread although they were submitted to the common ForkJoinPool before?
Here is an example in Java 16 (adopt-openjdk-16.0.1):
import java....
2
votes
1
answer
3k
views
Java execute code only after ForkJoinPool submit
I have 1 parallel processing code using ForkJoinPool:
ForkJoinPool customThreadPool = new ForkJoinPool(4);
customThreadPool.submit(() -> {
list.parallelStream().forEach(this::process);
});
I ...