Java concurrency
Hi,
I'm currently working on creating a threadpool that uses the worker thread pattern. I have a listener of sorts that receives tasks which are then fed to
ThreadPoolExecutor class. The code for this is shown below:
executor.execute(new ListenerQueueProcessor(key, value));
The run method of the ListenerQueueProcesser (The worker thread) is show here:
publicvoid run()
{
cacheStore.store(key, value);
}
I just have a question about how this should be working. Basically I have limited my ThreadPoolExecutor to a fixed thread pool of 10 threads. I have exposed this whole class using JMX so that I can monitor how may threads are running, the current queue etc etc. It seems that I only ever have one thread running. Could this be because the task I am giving it doesn't warrant creating another thread? If I place a Thread.sleep(2500) in my threads run() method, just to simulate a bit more work, it does go ahead and create the 10 threads when I bombard it with events.
Is there something I'm doing wrong or is it working as it should?
Is there a way to specify the wait a new task will wait for before deciding that it would be best to create a new thread?

