I have a Java Application which handles different region for example 10 regions. Each region have different number of tasks. I encounter a problem is that one particular region (Region A) have lots of tasks and the processing time of each task for that region is very long. Therefore, if I use a Single Thread Pool, and tasks of all
Tag: threadpool
Spring retry – Thread interruption handling
I am using spring-retry v1.3.1 with @Retryable annotation and I have a few questions on its behaviour. Let’s say that in my spring boot application I have a retry configuration that makes my application wait 1 hour before retrying. If my application is killed (for example by kubernetes) while it was waiting in order to do a retry is there
Why can’t I add tasks to the thread pool the second time in Java?
I create a thread pool to deal with the task, after deal with the task,I find I can not add and start the other task? How to fix it? If I change the executor by executor = new ThreadPoolExecutor(3, 3, 0L, TimeUnit.MILLISECONDS, new LinkedBlockingQueue<Runnable>(), new NamedThreadFactory(“timeOutThread”)); ,It will run OK.But if the task is canceled because of timeout,do this will
Graceful shutdown of multithreaded java server using executor service
I refactored a single-threaded server to be capable of multithreading and accepting multiple clients at the same time. To do so, I spawn a new ClientHandler thread for each new client and submit it to an ExecutorService. I want to initiate a server shutdown by entering a new line to System.In. However, I am not able to shut down the
Spring Boot async task stuck on shutdown
As per spring documentation for setWaitForTasksToCompleteOnShutdown Set whether to wait for scheduled tasks to complete on shutdown Does it mean that if any task is stuck on some long running process and we explicity try to stop the container, it will not be terminated untill that task is finished? Thanks for the answers. Answer Short answer? Yes On shutdown (
websphere work manager exceeding max threads
I have defined a work manager with max threads = 16 and it is not Growable. However, in the logs I can see thread numbering is as high as 180+. I suspect due to this, threads are getting starved waiting for resources and throwing a JDBC ConnectionWaitTimeoutException after 180 seconds. Why are so many threads getting spawned when the max
logback don’t log exception into file which throwed from an ThreadPoolTaskExecutor pool thread
I’ve got an wired problem, that seems like the logback only print my Exception stack trace on the console,rather than log it into an log file. The following is my experiment codes, I used an spring boot test with two thread pool,which simulating my production codes.Both thread print a log and throws an RuntimeException.But the exception info only print on
Accessing Java ThreadLocal object from a class other than where it was declared
I’m declaring a ThreadLocal object and setting a value like below. Is there anyway to reference this numberThreaLocalObj variable outside of this class within the same thread? I’ve found some code the seems to clear ALL the threadlocals, but I just need to clear this particular Threadlocal variable based on a condition. Unfortunately this is a inherited technical design. EDIT
Connection Pool and thread pool setting in Java
Spring application using Hikari pool. Now for a single request from the client I have to query 10 tables(business required), and then composite the result together. And querying for each table may cost 50ms to 200ms. To speed up the response time, I create a FixedThreadPool in my service to query each table in different thread(pseudocode): Now for a single
Java Scheduler Thread Switching
I’ve read somewhere that in Java scheduler, thread switching happens after execution of certain amount of instructions and not after a certain time (like schedulers used in operating systems). But the references were missing. I wanted to know if this is correct. Answer Java used to have a feature called GreenThreads, It was removed in 1.3. For all practical purposes