title: How to get a pthread name in C
body: <p>Say I create a pthread as <code>pthread_t lift_3;</code> and <code>pthread_create(&amp;lift_1, NULL, lift, share);</code>. When it goes into <code>lift()</code>, how can I get it the function to print the actual name of the thread? Or set a name for the thread?</p>
  
  <p>I have tried using <code>pthread_self()</code> to acquire the id, but it instead gives random numbers</p>
  
  <pre><code>#include &lt;stdio.h&gt; 
  #include &lt;stdlib.h&gt; 
  #include &lt;pthread.h&gt; 
  void* lift(void* ptr) 
  { 
      printf("thread name = %c\n", pthread_self()); 
      pthread_exit(NULL); 
      return NULL; 
  } 
  
  int main() 
  { 
      pthread_t lift_1; // declare thread 
      pthread_create(&amp;lift_1, NULL, lift, NULL); 
      pthread_join(lift_1, NULL);  
      return 0; 
  } 
  </code></pre>
  
  <p>The expected outcome should be <code>thread name = lift_1</code></p>