Solingen

thread

May 22nd, 2024
15
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.59 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <unistd.h> //Header file for sleep(). man 3 sleep for details.
  4. #include <pthread.h>
  5.  
  6. // A normal C function that is executed as a thread
  7. // when its name is specified in pthread_create()
  8. void *myThreadFun(void *vargp)
  9. {
  10. sleep(1);
  11. printf("Printing GeeksQuiz from Thread \n");
  12. return NULL;
  13. }
  14.  
  15. int main()
  16. {
  17. pthread_t thread_id;
  18. printf("Before Thread\n");
  19. pthread_create(&thread_id, NULL, myThreadFun, NULL);
  20. pthread_join(thread_id, NULL);
  21. printf("After Thread\n");
  22. exit(0);
  23. }
Add Comment
Please, Sign In to add comment