im trying to kick off a Runnable classes run method however i keep getting a NullPointerException, Im using WebSpheres commonj.workmanager to get an instance of executorService.this is the code im using.
executorService.execute(new Runnable()
{
public void run()
{
System.out.println("Inside run ()method..");
...
I have a webservice that does multiple small calculations before returning the result. I want to use the ExecutorService provided by Executors.newFixedThreadPool() as a way to implement the Master - Worker pattern (ie. call invokeAll and let the thread wait for all results to finish). Ideally all webservice threads use the same executor ...
I'm using a java.util.concurrent.ExecutorService that I obtained by calling Executors.newSingleThreadExecutor(). This ExecutorService can sometimes stop processing tasks, even though it has not been shutdown and continues to accept new tasks without throwing exceptions. Eventually, it builds up enough of a queue that my app shuts down wi...
Hey
I fail to understand why this code won't compile
ExecutorService executor = new ScheduledThreadPoolExecutor(threads);
class DocFeeder implements Callable<Boolean> {....}
...
List<DocFeeder> list = new LinkedList<DocFeeder>();
list.add(new DocFeeder(1));
...
executor.invokeAll(list);
The error msg is:
The method invokeAll(Col...
I am looking for a generic asynchronous Java job execution framework that could handle Callables or Runnables. It would be similar to java.util.concurrent.ExecutorService, (and possibly wrap ExecutorService), but it would also have the following features:
The ability to persist jobs to a database in case the application goes down while...
I am trying to port code from using java timers to using scheduledexecutorservice
I have the following use case
class A {
public boolean execute() {
try {
Timer t = new Timer();
t.schedule (new ATimerTask(), period, delay);
} catch (Exception e) {
return false;
...
I am currently hunting a nasty bug in a multi-threaded environment using FutureTasks and Executors. The basic idea is this to have a fixed number of threads execute individual FutureTasks that compute a result that is to be displayed in a a table (never mind the GUI aspect here).
I have been looking at this for so long, I am beginning ...
What are the advantages of using GridGain's GridExecutorService to execute jobs remotely vs using the @Gridify annotation?
You can pass an instance of java.lang.concurrent.ExecutorService to your class and have no dependency on the grid framework but do you lose any functionality?
...
I need to submit a number of task and then wait for them until all results are available. Each of them adds a String to a Vector (that is synchronized by default). Then I need to start a new task for each result in the Vector but I need to do this only when all the previous tasks have stopped doing their job.
I want to use Java Executor...
I have submitted a task using executors and I need it to stop after some time (e.g. 5 minutes). I have tried doing like this:
for (Future<?> fut : e.invokeAll(tasks, 300, TimeUnit.SECONDS)) {
try {
fut.get();
} catch (CancellationException ex) {
fut.cancel(true);
tasks.clea...
Hi,
I am using the Executor framework to kick off several threads using a threadpool i.e newFixedThreadPool. I use threadpool.submit(aThread) to submit jobs to be executed by the threadpool and this works fine however I need to determine when all the threads are complete so that I can continue with other processing. I looked at using F...
Suppose I have a task that is pulling elements from a java.util.concurrent.BlockingQueue and processing them.
public void scheduleTask(int delay, TimeUnit timeUnit)
{
scheduledExecutorService.scheduleWithFixedDelay(new Task(queue), 0, delay, timeUnit);
}
How can I schedule / reschedule the task if the frequency can be changed dyna...
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 program needs to process huge amount of data (stock market data) with as low latency as possible. Most of the calculations are fairly simple ar...
Hi StackOverflow,
i have this rather simple question about the ThreadPoolExecutor. I have the following situation: I have to consume objects from a queue, create the appropiate worker tasks for them and submit them to the ThreadPoolExecutor. This is quite simple. But within a shutdown scenario many workers may be queued to execution. Si...
I have seen several comments to the effect that Executors are better than Threads, but if you have a number of Threads communicating via bounded buffers (as in Flow-Based Programming) why would you use Executors when you have to use Threads anyway (with newCachedThreadPool (?)). Also, I use methods like isAlive(), interrupt() - how do I ...
I have been working with the example code from the ExecutorCompletionService and put together the following example code. The code in solve() works as expected and prints
1
2
3
4
5
The code in solve2() doesn't print anything and in fact never exits. It doesn't matter whether ecs is constructed before or after submitting the jobs to th...
I have a long running task that is executing in the background on an ExecutorService thread pool. What are some best practices in terms of this task returning progress or intermediate results? Are there any libraries that provide this functionality?
EDIT: To clarify, I'm talking about reporting progress to other code, not to the user....
I have a process which delegates asynch tasks to a pool of threads. I need to ensure that certain tasks are executed in order.
So for example
Tasks arrive in order
Tasks a1, b1, c1, d1 , e1, a2, a3, b2, f1
Tasks can be executed in any order except where there is a natural dependancy, so a1,a2,a3 must be processed in that order by ei...
The following code slides a card across the screen. When I shut down the main window, I expect the event dispatch thread to shut down as well, but it does not. Any ideas on why the ScheduledExecutorService thread prevents the EDT from shutting down?
import java.awt.Graphics;
import java.net.URL;
import java.util.concurrent.Executors;
im...
I'm wrestling with the best way to implement my processing pipeline.
My producers feed work to a BlockingQueue. On the consumer side, I poll the queue, wrap what I get in a Runnable task, and submit it to an ExecutorService.
while (!isStopping())
{
String work = workQueue.poll(1000L, TimeUnit.MILLISECONDS);
if (work == null)
...