title: Is there a way to ensure that threads are assigned to a specified set of objects?
body: <p>We are working on an application where a set of objects can be affected by receiving messages from 3 different sources. Each message (from any of the sources) has a single object as its target. Each message receiver will be running on its own thread. </p>
  
  <p>We want the processing of the messages (after receiving), to be as high-speed as possible, so the message processing against the target objects will be done with another thread from a thread pool. The processing of the message will take longer than the reading/receiving of the messages from the senders.</p>
  
  <p>I am thinking that it will be faster if each thread from the pool is dedicated only to a particular set of objects, for example:</p>
  
  <pre><code>Thread1 -&gt; objects named A-L
  Thread2 -&gt; objects named M-Z
  </code></pre>
  
  <p>with each set of objects (or Thread) having a dedicated queue of messages to pending being processed.  </p>
  
  <p>My assumption is that if the only thread synchronization needed is between each receiving thread and one processing thread, for the duration of time that it needs to put the message on a blocking queue, that it will be faster than randomly assigning worker threads to process the messages (in which case there might be 2 different threads with messages for the same object).</p>
  
  <p>My question is really 2 parts:</p>
  
  <ol>
  <li><p>Do people agree with the assumption that dedicating worker threads
      to a particular set of objects is a better/faster approach? </p></li>
  <li><p>Assuming this is a better approach, do the existing Java ThreadPool
      classes have a way to support this?  Or does it require us coding
      our own ThreadPool implementation?</p></li>
  </ol>
  
  <p>Thanks for any advice that you can offer.</p>