title: How to kill a running thread?
body: <blockquote>
    <p><strong>Possible Duplicate:</strong><br>
    <a href="https://stackoverflow.com/questions/2084830/kill-thread-in-pthread">kill thread in pthread</a>  </p>
  </blockquote>
  
  
  
  <p>Here after a source code containing a launch of thread and then after a while I want to kill it. How to do it ? <strong>Without make any change in the thread function</strong></p>
  
  <pre><code>#include &lt;stdlib.h&gt;
  #include &lt;stdio.h&gt;
  #include &lt;pthread.h&gt;
  
  pthread_t test_thread;
  
  void *thread_test_run (void *v) // I must not modify this function
  {
      int i=1;
      while(1)
      {
         printf("into thread %d\r\n",i);
         i++; 
         sleep(1);
      }
      return NULL
  }
  
  int main()
  {
      pthread_create(&amp;test_thread, NULL, &amp;thread_test_run, NULL);
  
      sleep (20);
      // Kill the thread here. How to do it?
  
     // other function are called here...
  
      return 0;
  }
  </code></pre>