title: Creating 100 threads in C++
body: <p>I am trying to learn about multithreading in C++. I'm trying to create 100 threads with a loop by using an array of threads but I am getting an error. It gives this error:</p>
  
  <pre><code>error: array initializer must be an initializer list
  thread threads[i](task1, list[i]);
  </code></pre>
  
  <p>Here is the code:</p>
  
  <pre><code>static int list [100] = {};
  thread threads [100] = {};
  
  
  void task1(int n)
  {
    for (int i = 0; i &lt; 10; i++)
      n = n + 1;
  }
  
  int main()
  {
    for (int i = 0; i &lt; sizeof(list); i++){
      thread threads[i](task1, list[i]);
      threads[i].join();
    }
  
    int total = 0;
    for (int i = 0; i &lt; sizeof(list); i++)
      total += list[i];
  
    cout &lt;&lt; total &lt;&lt; endl;
  
    return 0;
  }
  </code></pre>