title: How to add threads depending on a number
body: <p>In a part of my software code written with python, I have a list of items where it size can vary greatly from 12 to only one item . For each item in this list I'm doing some processing (sending an HTTP request related to the given item, parse results and many other operations . I'd like to speed up my code using threading, I'd like to create 2 threads where each one take a number of items and do the processing async. </p>
  
  <p><strong>Example 1</strong> : Let's say that in my list I have 12 items, each thread would take in this case 6 items and call the processing functions on each item .</p>
  
  <p><strong>Example 2</strong> : Now let's say that my list have 9 items, one thread would take 5 items and the other thread would take the other 4 left items .</p>
  
  <p>Currently I'm not applying any threading and my code base is very large, so here some code that do almost the same thing as my case :</p>
  
  <pre><code>#This procedure need to be used with threading .
  itemList = getItems() #This function return an unknown number of items between 1 and 12
  
  if len(itemList) &gt; 0: # Make sure that the list is empty in this case .
      for item in itemList:
          processItem(item) #This is an imaginary function that do the processing on each item 
  </code></pre>
  
  <p>Below is a basic lite code that explain what I'm doing, I can't figure out how can I make my threads flexible, so each one take a number of items and the other take the rest (as explained in example 1 &amp; 2) .</p>
  
  <p>Thank's for your time</p>