Programming

linux thread.c

daehee87 2013. 3. 19. 15:19

#include <stdio.h>

#include <pthread.h>


pthread_t th;


void* func(void* a){


while(1){

printf("thread running...%d\n", getpid());

sleep(5);

}


}


int main(){


pthread_create( &th, 0, func, 0);

pthread_detach( th );

while(1){

printf("main thread running...%d\n", getpid());

sleep(5);

}

return 0;

}