title: Misunderstanding the difference between single-threading and multi-threading programming
body: <p>I have a misunderstanding of the difference between single-threading and multi-threading programming, so I want an answer to the following question to make everything clear.</p>
  
  <p>Suppose that there are 9 independent tasks and I want to accomplish them with a single-threaded program and a multi-threaded program. Basically it will be something like this:</p>
  
  <p><strong>Single-thread:</strong></p>
  
  <pre><code>- Execute task 1
  - Execute task 2
  - Execute task 3
  - Execute task 4
  - Execute task 5
  - Execute task 6
  - Execute task 7
  - Execute task 8
  - Execute task 9
  </code></pre>
  
  <p><strong>Multi-threaded:</strong></p>
  
  <p><strong>Thread1:</strong></p>
  
  <pre><code>- Execute task 1
  - Execute task 2
  - Execute task 3
  </code></pre>
  
  <p><strong>Thread2:</strong></p>
  
  <pre><code>- Execute task 4
  - Execute task 5
  - Execute task 6
  </code></pre>
  
  <p><strong>Thread3:</strong></p>
  
  <pre><code>- Execute task 7
  - Execute task 8
  - Execute task 9
  </code></pre>
  
  <p>As I understand, only <em>ONE</em> thread will be executed at a time (get the CPU), and once the quantum is finished, the thread scheduler will give the CPU time to another thread.</p>
  
  <p>So, which program will be finished earlier? Is it the multi-threaded program (logically)? or is it the single-thread program (since the multi-threading has a lot of context-switching which takes some time)? and why? I need a good explanation please :)</p>