Java ThreadPool for multiple identical tasks
Posted
by
tdimmig
on Stack Overflow
See other posts from Stack Overflow
or by tdimmig
Published on 2012-08-31T21:32:41Z
Indexed on
2012/08/31
21:38 UTC
Read the original article
Hit count: 155
I have 1 thread who sole job is to grab DatagramPackets off of a socket and stick them in a buffer. Another thread works out of that buffer, processing the DatagramPackets. I'd like to have a pool of threads working out of that buffer.
I had thought to use a fixed thread pool to do this. To do so, do I need to create the pool, then submit enough runnables for execution to fill it up? I had hoped for a way to say "this is the thread/runnable that I want you to execute, this is how many I want running, GO!". Is there such a method of doing this? Is something other than a fixed thread pool better suited?
© Stack Overflow or respective owner