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, ... |
newCachedThreadPool() V/s newFixedThreadPool(...)
when to use and which is better in terms of resource utilisation?
|
Executor seems like a clean abstraction. When would you want to use Thread directly rather than rely on the more robust executor?
|
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. ... |
Number of tasks (threads) submitted is also not huge in this test scenario.
|
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 ... |
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 ...
|
|
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 ...
|
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 ... |
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. ... |
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. ... |
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 ... |
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 ... |
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?
|
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 ... |
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() ...
|
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 |
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 ... |
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 ... |
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 ... |
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 ... |
Consider the following code snipet:
public class A {
private final Executor executor = Executors.newCachedThreadPool();
private final Queue<Object> messageQueue = new ConcurrentLinkedQueue<M>();
public ...
|
|
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 ... |
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 ... |