Advertisement
Mastercpp

Hilos C

Sep 6th, 2015
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.48 KB | None | 0 0
  1. #include<stdio.h>
  2. #include <stdlib.h>
  3. #include <windows.h>
  4. #include <pthread.h>
  5.  
  6. void * procesoSeparado(void * data){
  7.     char * texto = (char *) data;
  8.    
  9.     while(1){
  10.         printf("%s\n",texto);
  11.         Sleep(1000);
  12.     }
  13. }
  14.  
  15.  
  16. int main(){
  17.    
  18.     pthread_t proceso1;
  19.     pthread_t proceso2;
  20.     pthread_create(&proceso1 , NULL , &procesoSeparado, "hola");
  21.     pthread_create(&proceso2, NULL, &procesoSeparado,"adios" );
  22.     pthread_join(proceso1, NULL);
  23.     pthread_join(proceso2 , NULL);
  24.    
  25.    
  26.     return 0;
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement