Questions tagged [executorservice]

ExecutorService is a Java object containing the managed pool of threads and capable of scheduling the submitted tasks for these threads. The scheduling strategies vary in multiple available implementations.

0
votes
1answer
24 views

How to assure all threads are stopped with shutdownNow()?

I'm using Java's ExecutorService to run some tasks concurrently. I'm faced with this situation where I have multiple threads updating my DB, and if any of them throw an exception, I want to stop all ...
0
votes
0answers
24 views

Editing a file concurrently in JAVA null pointer exception [duplicate]

I am working an XML string with some 8931 records. I want to access some tags perform some split functions and trim functions before saving it. I tried using simple loops but it is taking a long time(...
-1
votes
0answers
10 views

Nullpointer Exception when trying to change a file parallely [duplicate]

I am working an XML string with some 8931 records. I want to access some tags perform some split functions and trim functions before saving it. I tried using simple loops but it is taking a long time(...
0
votes
2answers
21 views

Shutdown @Bean ExecutorService using @PreDestroy

I have a Spring @Configuration class as follows:@Configurationpublic class ExecutorServiceConfiguration {@Beanpublic BlockingQueue<Runnable> queue() {return ...
-1
votes
1answer
51 views

Java Executors are not calling for all the for loop iteration

I am trying to run executors for a 100 tasks. Currently, it is working for 10 tasks but when I send a request with 11 tasks, 1 will fail(anything above 10 will fail). When I debugged it I realized ...
1
vote
0answers
41 views

Spring web application and asynchronous executions using thread pool

I have a spring application which acts as a orchestrator whose responsibility is to aggregate results from 6+ other spring web application whose results are mutually exclusively from each other, ...
-1
votes
1answer
42 views

Do Java Executors run in a daemon thread?

I had a short java program that created a single thread scheduled executor and I scheduled a task.ScheduledExecutorService scheduledExecutorService=Executors.newSingleThreadScheduledExecutor();...
1
vote
1answer
21 views

Android Thread Execution Slows Down when screen locks

Iam running this procedure to download some data and insert them into the database. The total procedure takes around 5 minutes. I noticed that while downloading, when the phone locks the screen and ...
1
vote
2answers
56 views

Stop thread that's already running

I have two APIs: one starts the thread, and another stops the thread. I'm successfully able to start a thread by calling /start API, but I'm unable to stop already running thread by calling /stop API. ...
2
votes
1answer
46 views

How to have java executor with same thread?

For some proposes, I need to create an Executor which has always one same thread.Executors.newFixedThreadPool(1);Executors.newScheduledThreadPool(1);Above examples create one thread pool but when ...
0
votes
0answers
36 views

With and without use of Executors.newSingleThreadExecutor

Please help me to figure out the best solution. I need to handle some event and validate and process. I have implemented and it is working fine with Approach 1 mentioned below. But I have got a ...
3
votes
3answers
68 views

ExecutorService vs CompletableFuture

I have been trying to implement an asynchronous process, where the parent method calls a child method which would in-turn call three different methods. I want all of this process to be done ...
0
votes
4answers
43 views

Losing ApplicationContext when executing new runnables

I know I'm new to this spring stuff but I've been stuck on this all day. I don't much like asking questions but maybe I'll get an idea.So here's my problem:I'm trying to create a Queue for ...
0
votes
3answers
46 views

Trying to speed up this for loop but I can't using Callable implementation

This is the sequential loop:private boolean canSpawnVehicle(SpawnPoint spawnPoint) {// TODO: can be made much faster.Rectangle2D noVehicleZone=spawnPoint.getNoVehicleZone();for(VehicleSimView ...
0
votes
0answers
28 views

Is this the right way to use Callable?

I have a big text file to be processed. The method parse() is trying to use multiple threads to send requests to a restful service to get back results. For each inputInfo, it should return an ...
1
vote
2answers
59 views

Java ExecutorService usage

I'd like to make a 2 threaded application like the following:Create 2 threaded pool Run a foo method on the #1 threadWait 2 secondsRun bar method on #2 threadThe 2 threaded pool should wait a ...
1
vote
1answer
28 views

ManagedExecutorService not found

I have a problem with Arquillian and ManagedExecutorServices. Arquillian is not able to find the default ManagedExecutorService. The Exception is:Caused by: javax.naming.NameNotFoundException: No ...
1
vote
2answers
40 views

Do I need to handle exception in executorservice

Did I need to handle runtime exception in executorservice? I tried an example in spring boot web application, the code will still execute despite of exception Here is the code:@RestController...
1
vote
1answer
25 views

Process 1 record from a list of record only once using multithreading

I have a list which contains X number of records. I want to process these records using multiple threads. Currently I have taking out the records and sending it for execution. When I printed the ...
0
votes
0answers
35 views

Java, thread don't continue with Hibernate

Sorry for my EnglishI have a big problem with my program, I would create a data generator simulator with Spring MVC. This is code :Class Executor: public class ExecutorHerga {public ...
0
votes
1answer
26 views

How works ScheduledExecutorService if call scheduleWithFixedDelay method more times than pool size?

In this code I create ScheduledExecutorService with pool of 5 threads and call scheduleWithFixedDelay method 5 tims. It will create 5 schedulers and each scheduler will call testBean::test every ...
1
vote
1answer
28 views

A common executorservice(fixed thread pool) for complete web application or a new thread pool using executorService for each and every request?

To improve the response time of my request, I was planning to use executorService and divide my work among multiple threads and reduce the response time of the request.But after reading articles and ...
1
vote
2answers
76 views

How to improve performance of multi threading

I have googled and found the best way to use multithreading but its failing for a 100 records it giving 504 status code. Is there any scope to improve the below code?@Scheduled(fixedRate=5000)...
0
votes
1answer
35 views

Comparison between shutting down an executor service (while awaiting termination) and wait cancellation of submitted tasks (using submit's futures)

So the proposed best practice by Oracle itself for shutting down an ExecutorService would be the following:@PreDestroypublic void cleanUp(){executorService.shutdown();try {...
1
vote
2answers
38 views

Java CompletableFuture assigning executor

I am having confusion with defining executor in CompletableFuture. I am not sure how to tell CompletableFuture to run it in that particular executor. Thanks in advancehttp://Suppose I have an executor...
1
vote
3answers
39 views

what is the best way to know when all submitted tasks has been finished by Executor Service

here is two options , just bit confuse which one is best to go.Option 1:ExecutorService es=Executors.newFixedThreadPool(4);List<Runnable> tasks=getTasks();CompletableFuture<?>[] ...
2
votes
1answer
43 views

How does corePoolSize=0 work for ThreadPoolExecutor?

The definition for ExecutorService.newCachedThreadPool() ispublic static ExecutorService newCachedThreadPool(ThreadFactory threadFactory) {return new ThreadPoolExecutor(0, Integer.MAX_VALUE,...
1
vote
1answer
14 views

App keeps trying to restart message service, how do I run the message service only once?

I have an app that runs an executor service with 2 runnables that start the process to receive messages from a rfid reader. This reader receives a message from the messagelistener that contains the ...
0
votes
1answer
30 views

Is there an ExecutorService implementation with queue limit and an option to replace old queue members with new ones?

I need an ExecutorService implementation that can limit how many Runnables can be queued. I would also like to be able to control what happens when new runnables are submitted while the queue is ...
0
votes
1answer
52 views

How to track and implement cancel option for nested Runnable in java

I am working on a Java application which uses ZMQ to handle request. My code have some nested Runnable which are as in following structure:private class SomeRunnable implements Runnable {@...

153050per page
angop.ao, elkhabar.com, noa.al, afghanpaper.com, bbc.com, time.com, cdc.gov, nih.gov, xnxx.com, github.com,