#include <stdio.h>
#include <pthread.h>
void *Count (void *);
int main(int argc, char **argv)
{
pthread_t p_thread[2];
int pthread_status;
pthread_create(&p_thread[0], NULL, Count, (void *)NULL);
pthread_create(&p_thread[1], NULL, Count, (void *)NULL);
pthread_join(p_thread[0], (void **)&pthread_status);
pthread_join(p_thread[1], (void **)&pthread_status);
return 0;
}
void *Count (void *arg)
{
pthread_t thread_id = pthread_self();
int num = 0;
while (num < 10)
{
printf ("%x : %d\n", thread_id, num);
num++;
sleep(1);
}
}
'Coding > CPP 삽질기' 카테고리의 다른 글
함수 포인터 (0) | 2009.01.08 |
---|---|
[CPP] STL에서 List의 sorting 방법 (0) | 2008.10.30 |
Copy & Paste 신공 (0) | 2008.03.08 |