title: C++ 11 threading error
body: <p>I have a C++11 program that gives me this error:</p>
  
  <pre><code>terminate called after throwing an instance of 'std::system_error'
  what():  Operation not permitted
  </code></pre>
  
  <p>Code:</p>
  
  <pre><code>const int popSize=100;
  void initializePop(mt3dSet mt3dPop[], int index1, int index2, std::string ssmName, std::string s1, std::string s2, std::string s3, std::string s4, std::string mt3dnam, std::string obf1, int iNSP, int iNRM, int iNCM, int iNLY, int iOPT, int iNPS, int iNWL, int iNRO, int ssmPosition, int obsPosition ){
    if((index1 &gt;= index2)||index1&lt;0||index2&gt;popSize){
      std::cout&lt;&lt;"\nInitializing population...\nIndex not valid..\nQuitting...\n";
      exit(1);
    }
    for(int i=index1; i&lt;index2; i++){
      mt3dPop[i].setSSM(ssmName, iNSP, iNRM, iNCM, iNLY);
      mt3dPop[i].setNam(toString(s1,s3,i));
      mt3dPop[i].setObsName(toString(s1,s4,i));
      mt3dPop[i].setSsmName(toString(s1,s2,i));
      mt3dPop[i].getSSM().generateFl(toString(s1,s2,i),iOPT,iNPS);
      mt3dPop[i].generateNam(mt3dnam, ssmPosition, obsPosition);
      mt3dPop[i].setFitness(obf1, iNWL, iNRO);
    }}
  
  void runPackage(ifstream&amp; inFile){
  //all variables/function parameters for function call are read from inFile
  unsigned int numThreads = std::thread::hardware_concurrency();// =4 in my computer
  std::vector&lt;std::thread&gt; vt(numThreads-1);//three threads
  for(int j=0; j&lt;numThreads-1; j++){
      vt[j]= std::thread(initializePop,mt3dPop,j*popSize/numThreads, (j+1)*popSize/numThreads, ssmName, s1,s2, s3, s4, mt3dnam,obf1,iNSP, iNRM, iNCM, iNLY, iOPT, iNPS, iNWL, iNRO, ssmPosition, obsPosition );   //0-24 in thread 1, 25-49 in thread 2, 50-74 in thread 3            
  }
  //remaining 75 to 99 in main thread
  initializePop(mt3dPop,(numThreads-1)*popSize/numThreads, popSize, ssmName, s1,s2, s3, s4, mt3dnam,obf1,iNSP, iNRM, iNCM, iNLY, iOPT, iNPS, iNWL, iNRO, ssmPosition, obsPosition);        
  
  for(int j=0; j&lt;numThreads-1; j++){
      vt[j].join();
  }}
  </code></pre>
  
  <p>What does the error mean and how do I fix it?</p>