#include <stdio.h> #include <stdlib.h> #include <pthread.h> using namespace std; void* function1(void* data) { printf( "Vine al cole: %s\n", (char*)data ); return 0; } int main() { int thread1ID, thread2ID; pthread_t thread1, thread2; char rufol[] = "rufol"; char lucky[] = "lucky"; thread1ID = pthread_create ( &thread1, // the thread 0, // attributes function1, // function to call (void*)rufol // parameter pointer for the called function ); thread2ID = pthread_create ( &thread2, // the thread 0, // attributes function1, // function to call (void*)lucky // parameter pointer for the called function ); pthread_join(thread1, 0); pthread_join(thread2, 0); }
viernes, 20 de febrero de 2015
pthreads exemple
Suscribirse a:
Enviar comentarios (Atom)
No hay comentarios:
Publicar un comentario