Hola Visitante

Autor Tema: Threading C  (Leído 1295 veces)

Berni69

  • Administrator
  • *****
  • Mensajes: 25
    • Ver Perfil
Threading C
« en: Noviembre 16, 2011, 08:45:42 am »
Creo que este código se explica por si solo no?

Código: (C) [Seleccionar]
#include
#include
#include
 
void foo_Thread(char *input) {
printf(\"Inside %s\", input);
}
 
int main(void) {
 
pthread_t thread1, thread2;
char *str1 = \"Thread one\";
char *str2 = \"Thread two\";
int ret1, ret2;
 
/* Create independent threads each of which will execute function */
 
ret1 = pthread_create( &thread1, NULL, foo_Thread, (void*) str1);
ret2 = pthread_create( &thread2, NULL, foo_Thread, (void*) str2);
 
/* Wait till threads are complete
  pthread_join( thread1, NULL);
  pthread_join( thread2, NULL);
 
  printf(\"Thread one returns: %d\\\\n\",iret1);
  printf(\"Thread two returns: %d\\\\n\",iret2);
  exit(0);
 
}