title: static mutex and multithreading
body: <p>If I declare a mutex as static in a function and use that mutex to lock a certain variable. Is that mutex 'shared' between threads, e.g I can get away with using a little bit of cleaner code?</p>
  
  <p>example of appending a string to a double pointer char type, I want to call something like this from multiple threads:</p>
  
  <pre><code>void func(char *msg) {
      static pthread_mutex_t mtx = PTHREAD_MUTEX_INITIALIZER;
      static char **buffer;
      static unsigned int i=0;
  
      pthread_mutex_lock(&amp;mtx);
      buffer = realloc(++i * sizeof(char *));
      buffer[i-1] = realloc(strlen(msg) + 1);
      strcpy(buffer[i-1], msg);
      pthread_mutex_unlock(&amp;mtx);
  
      return;
  
  }
  </code></pre>