Advertisement
minh_tran_782

Hello from thread

Feb 23rd, 2022
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.29 KB | None | 0 0
  1. #include <stdio.h>
  2.  #include <pthread.h>
  3.  void* hello (void* tid ) {
  4.   printf ("Hello␣from␣thread␣%d\n" , (int) tid ) ;
  5.  }
  6.  int main() {
  7.  pthread_t tid [ 10 ] ;
  8.  int i ;
  9.   for ( i = 0; i < 10; i++) {
  10.   pthread_create(&tid[i] , NULL, hello , (void*)i ) ;
  11.  }
  12.  pthread_exit (NULL) ;
  13.  }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement