title: C Pthread taking much longer than single threaded
body: <p>I've made a matrix multiplier piece of code designed to quantify how much faster threading is for each size of matrix. The code where threads are made and executed is below. I'm new to threading but whenever I use threading it seems to take about 12 times longer, am I doing something wrong or does anyone know why it's so much slower?</p>
  
  <p>Thanks,</p>
  
  <pre><code>void *vectorMultiply(void *arguments){
      struct vectorV *args = arguments;
  
      int sum = 0;
      for (int iii = 0; iii &lt; args-&gt;n; iii++) {
          sum = sum + args-&gt;first[args-&gt;i][iii] * args-&gt;second[iii][args-&gt;ii];
      }
      args-&gt;out[args-&gt;i][args-&gt;ii] = sum;
  }
  
  void singleThreadVectorMultiply(int n,int i,int ii, int 
                                  **first, int **second, int **out){
      int sum = 0;
      for (int iii = 0; iii &lt; n; iii++) {
          sum = sum + first[i][iii] * second[iii][ii];
      }
      out[i][ii] = sum;
  }
  
  void multiplyMatrix(int n, int** first, int** second, int** out){
      pthread_t tid[n][n]; 
      struct vectorV values[n][n];
      for (int i = 0; i &lt; n; i++) {
          for (int ii = 0; ii &lt; n; ii++) {
              if(!SINGLETHREAD){
                  values[i][ii].n=n;
                  values[i][ii].i=i;
                  values[i][ii].ii=ii;
                  values[i][ii].first = first;
                  values[i][ii].second=second;
                  values[i][ii].out=out;
                  pthread_create(&amp;tid[i][ii], NULL, vectorMultiply, 
                                (void *)&amp;values[i][ii]); 
              }
              else{
                  clock_t time; 
                  time = clock(); 
                  singleThreadVectorMultiply(n,i,ii,first,second,out);
                  time = clock() - time; 
                  totalTime+=time;
              }
  
          }
      }
      if(!SINGLETHREAD){
          clock_t time; 
          time = clock(); 
          for(int i=0; i &lt; n; i++)
              for(int ii=0; ii &lt; n; ii++)
                  pthread_join( tid[i][ii], NULL); 
          time = clock() - time; 
          totalTime+=time;
      }
  }
  </code></pre>