VOOZH about

URL: https://www.geeksforgeeks.org/c/pthread_cancel-c-example/

⇱ pthread_cancel() in C with example - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

pthread_cancel() in C with example

Last Updated : 6 Sep, 2017
prerequisite: Multithreading, pthread_self() in C with Example pthread_cancel() = This function cancel a particular thread using thread id. This function send a cancellation request to the thread. Syntax : - int pthread_cancel(pthread_t thread); First Program : - Cancel self thread   Output:
GeeksForGeeks
  If you use Linux then compile this program gcc program_name.c -lpthread Second Program : - Cancel other thread  
Output:
thread number one
thread number two
thread number one 
thread number two
  If you use Linux then compile this program gcc program_name.c -lpthread
Comment
Article Tags: