executor « concurrency « Java Thread Q&A

Home
Java Thread Q&A
1.concurrency
2.Development
3.Exception
4.Notify
5.Operation
6.Socket
7.State
8.synchronize
9.Thread Safe
10.ThreadPool
Java Thread Q&A » concurrency » executor 

1. Is there a .Net equivalent to java.util.concurrent.Executor?    stackoverflow.com

Have a long running set of discrete tasks: parsing 10s of thousands of lines from a text file, hydrating into objects, manipulating, and persisting. If I were implementing this in Java, ...

2. newCachedThreadPool() V/s newFixedThreadPool    stackoverflow.com

newCachedThreadPool() V/s newFixedThreadPool(...)
when to use and which is better in terms of resource utilisation?

3. When should we use Java's Thread over Executor?    stackoverflow.com

Executor seems like a clean abstraction. When would you want to use Thread directly rather than rely on the more robust executor?

4. How to shut down all Executors when quitting an application?    stackoverflow.com

According to Brian Goetz's Java Concurrency in Practice JVM can't exit until all the (nondaemon) threads have terminated, so failing to shut down an Executor could prevent the JVM from exiting. I.e. ...

5. Why does Executors.newCachedThreadPool throw java.util.concurrent.RejectedExecutionException during submit    stackoverflow.com

Number of tasks (threads) submitted is also not huge in this test scenario.

6. How to properly catch RuntimeExceptions from Executors?    stackoverflow.com

Say that I have the following code:

ExecutorService executor = Executors.newSingleThreadExecutor();
executor.execute(myRunnable);
Now, if myRunnable throws a RuntimeExcpetion, how can I catch it? One way would be to supply my own ThreadFactory implementation to ...

7. Elegantly implementing queue length indicators to ExecutorServices    stackoverflow.com

Why, oh why doesn't java.util.concurrent provide a queue length indicators for its ExecutorServices? Recently I found myself doing something like this:

ExecutorService queue = Executors.newSingleThreadExecutor();
AtomicInteger queueLength = new AtomicInteger();
...

public void addTaskToQueue(Runnable ...

8. When does the call() method get called in a Java Executor using Callable objects?    stackoverflow.com

This is some sample code from an example. What I need to know is when call() gets called on the callable? What triggers it?

public class CallableExample {

public static class ...

9. Java: design for using many executors services and only few threads    stackoverflow.com

I need to run in parallel multiple threads to perform some tests.

My 'test engine' will have n tests to perform, each one doing k sub-tests. Each test result is stored for ...

10. Should I limit the number of Executors I have?    stackoverflow.com

I have a Java project where I need to run things in parallel. I do this with executors. The thing is, I need to use executors in a great many places. ...

11. Executor in java    stackoverflow.com

I was trying to run ExecutorService object with FixedThreadPool and I ran into problems. The trouble was that I expected the program to run in nanoseconds while it hung up on me. ...

12. Why does this code not see any significant performance gain when I use multiple threads on a quadcore machine?    stackoverflow.com

I wrote some Java code to learn more about the Executor framework. Specifically, I wrote code to verify the Collatz Hypothesis - this says that if you iteratively ...

13. Do I have to manually shut down an Executor at application exit?    stackoverflow.com

Suppose I have an Executor executor; somewhere in my application. Is it sufficient to just say setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); as usual and let "the system" deal with it, or do I have to ...

14. How does java.util.concurrent.Executor work?    stackoverflow.com

How does java.util.concurrent.Executor create the "real" thread? Suppose I am implementing Executor or using any executor service (like ThreadPoolExecutor). How does JVM internally work?

15. Could not start more threads despite using Executors    stackoverflow.com

i have been advised to use Executors.newCachedThreadPool() which will be able to solve problems when over-spawning threads. However there is still an error when the number of threads is growing past a ...

16. Simple thread problem    stackoverflow.com

I started learning java and I am now at the concurrency chapter. After reading some stuff about concurrency I tried an example of my own.

public class Task implements Runnable{

public void run() ...

17. ExecutorService slow multi thread performance    stackoverflow.com

I am trying to execute a simple calculation (it calls Math.random() 10000000 times). Surprisingly running it in simple method performs much faster than using ExecutorService. I have read another thread at

18. Executors use and cost penalty    stackoverflow.com

Some questions about Executors best usage for memory and time performance: -1- Is there any cost penalty from using

ExecutorService e=Executors.newSingleThreadExecutor();
e.execute(callable)
e.shutdown()
compared to:
new Thread(runnable).start()
-2- If a Callable is not a long one, and never won't be ...

19. What is the exit strategy for Executors.newSingleThreadExecutor()    stackoverflow.com

I'm new to java concurrency so this may be a question already answered many time over or too obvious that I maybe missing something. I am running as task like so: Executors.newSingleThreadExecutor().execute(task) My question ...

20. Difference between Executor and ExecutorCompletionservice in java    stackoverflow.com

As the question title itself says what is the difference between Executors and ExecutorCompletionService classes in java? I am new to the Threading,so if any one can explain with a piece of ...

21. How to manage executors    stackoverflow.com

It's not infrequent in my practice that software I develop grows big and complex, and various parts of it use executors in their own way. From the performance point of view ...

22. Executor.execute() JMM guarantee    stackoverflow.com

Consider the following code snipet:

public class A {

    private final Executor executor = Executors.newCachedThreadPool();
    private final Queue<Object> messageQueue = new ConcurrentLinkedQueue<M>();

    public ...

23. Concurrency, Executors    forums.oracle.com

24. help me regards perfomance:java.util.concurrent.Executors    forums.oracle.com

hi friends, I implemented the concurrent.Executors in my project. to tell my problem consider a program that insert 1000 data into oracle database. instead of inserting 1000 data as a single operations i created 5 threads using the concurrent API. and inserted 200 records per thread. when i analyse the time(in miliseconds) i got the following result, insert the 1000 records ...

25. java.util.concurrent.Executor.execute()    forums.oracle.com

Hi all, The API for java.util.concurrent.Executor.execute() says: Executes the given command at some time in the future. The command may execute in a new thread, in a pooled thread, or in the calling thread, at the discretion of the Executor implementation. If the calling thread is the EDT and I need to process something on a separate thread to free the ...

java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.