title: Thread and Queue
body: <p>I am interested in knowing what would be the best way to implement a thread based queue.</p>
  
  <p>For example:</p>
  
  <p>I have 10 actions which I want to execute with only 4 threads. I would like to create a queue with all the 10 actions placed linearly and start the first 4 action with 4 threads, once one of the thread is done executing, the next one will start etc - So at a time, the number of thread is either 4 or less than 4.</p>