executorservice Questions

4

Solved

I have a scenario where I have to execute 5 thread asynchronously for the same callable. As far as I understand, there are two options: 1) using submit(Callable) ExecutorService executorService =...
Englut asked 23/12, 2015 at 17:10

5

Solved

I have the following Java code: final Future future = exeService.submit( new Runnable() { public void run() { myObject.doSomething(); } } ); future.get(); where exeService is an instance o...

5

Solved

Ok, so I know the first answer / comment here will be "use one ExecutorService and use invokeAll". However, there is a good reason (which I will not bore people with) for us keeping the thread pool...
Flavory asked 1/11, 2012 at 18:55

11

I am trying to execute lots of tasks using a ThreadPoolExecutor. Below is a hypothetical example: def workQueue = new ArrayBlockingQueue<Runnable>(3, false) def threadPoolExecutor = new Thre...

11

How to unit test a code that is running in executor service? In my situation, public void test() { Runnable R = new Runnable() { @Override public void run() { executeTask1(); executeTask2(); ...
Incomparable asked 24/9, 2017 at 18:54

2

Solved

I have just upgraded our Spring Boot applications to Java 21. As a part of that, I have also done changes to use virtual threads. Both when serving API requests and when doing async operations inte...
Ablation asked 26/2, 2024 at 12:51

21

Solved

Let's say I have an application that utilizes the Executor framework as such Executors.newSingleThreadExecutor().submit(new Runnable(){ @Override public void run(){ // do stuff } } When I ru...
Overmatch asked 24/5, 2011 at 16:33

2

Solved

Motivation: Trying to migrate Virtual Threads. Problem: Even though Virtual Threads are cheap, OS may find it suspicious for some processes to be stacked up at the same time, like searching for IP ...
Mcadams asked 4/2, 2024 at 21:46

3

Solved

In a utility library i am creating a ExecutorService ExecutorService es = Executors.newSingleThreadExecutor(); The main thread will then post some tasks to this ExecutorService. When the main-th...
Spontaneity asked 23/11, 2013 at 13:55

17

What is the simplest way to to wait for all tasks of ExecutorService to finish? My task is primarily computational, so I just want to run a large number of jobs - one on each core. Right now my set...
Darvon asked 16/7, 2010 at 23:12

5

Solved

I have a command line application that uses a Spring-managed bean that's composed of a java ExecutorService created with: ExecutorService service = Executors.newFixedThreadPool(4); Now, I want m...
Horseleech asked 29/8, 2013 at 16:19

2

We've recently started using coroutines on our Android application. All's gone fine and dandy, until someone wrote something roughly equivalent to the following function: fun example(dispatcher: C...
Mutualize asked 11/4, 2018 at 22:26

10

Solved

What is the difference between ExecutorService eService = Executors.newFixedThreadPool(2); eService.execute(new TestThread6()); eService.execute(new TestThread6()); eService.execute(new TestThread...
Postage asked 25/8, 2013 at 2:17

6

I was reading about it quite a bit in the past couple of hours, and I simply cannot see any reason (valid reason) to call shutdown() on the ExecutorService, unless we have a humongous application t...
Franck asked 20/4, 2013 at 17:9

2

Solved

I need to unit-test some functionality that works across threads, for which I need to guarantee that two jobs are run on different threads. Using Executors.newCachedThreadPool() introduces a race...
Accounting asked 6/7, 2017 at 13:32

9

Solved

I am learning to use ExectorService to pool threads and send out tasks. I have a simple program below import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; import jav...
Nausea asked 10/9, 2013 at 23:22

3

Solved

I am going through different concurrency model in multi-threading environment (http://tutorials.jenkov.com/java-concurrency/concurrency-models.html) The article highlights about three concurrency m...

11

Solved

I'm trying to figure out how to correctly use Java's Executors. I realize submitting tasks to an ExecutorService has its own overhead. However, I'm surprised to see it is as high as it is. My prog...
Lumberman asked 30/10, 2009 at 4:17

4

Solved

I've a web application using the spring(4.2.x) artifacts spring-webmvc, spring-messaging, spring-websocket I've the below @Enable* annotations in my spring config java class @EnableWebMvc @Enable...
Presbyterate asked 4/8, 2015 at 18:13

3

Solved

I'v got ConcurrentLinkedDeque which I'm using for synchronic push/pop elements, and I'v got some async tasks which are taking one element from stack and if this element has neighbors It's pushing ...
Coddle asked 21/11, 2015 at 15:53

13

Solved

I'm trying to use Java's ThreadPoolExecutor class to run a large number of heavy weight tasks with a fixed number of threads. Each of the tasks has many places during which it may fail due to excep...

3

Whenever I call shutdownNow() or shutdown() it doesn't shut down. I read of a few threads where it said that shutting down is not guaranteed - can someone provide me a good way of doing it?
Mokas asked 8/5, 2012 at 18:17

8

Solved

Summary of what I want to achieve: I want to execute N tasks in parallel such that no individual task should run for more than two seconds (we can mark such tasks as failed). As an output I want to...
Dona asked 2/3, 2022 at 11:58

1

Currently I'm using an Executors.newSingleThreadScheduledExecutor() to schedule a task periodically. The ScheduledExecutorService provides two options for this, namely: ScheduledExecutorService#sc...

6

The service I'm working on uses a Future to run multiple tasks in parallel; each task can take up to a minute to complete. However, it seems the external lib is buggy, since in some occasions (2% o...
Alkalosis asked 12/3, 2022 at 16:43

© 2022 - 2025 — McMap. All rights reserved.