달력

10

« 2017/10 »

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  •  
  •  
  •  
  •  

'삽질예방/pthread'에 해당되는 글 1

  1. 2008.01.22 pthread 예제
2008.01.22 01:34

pthread 예제 삽질예방/pthread2008.01.22 01:34


#include <STDIO.H> #include <PTHREAD.H> #include <SEMAPHORE.H> void* PrintHelp(void* nothing); void* PrintHelp2(void* nothing); sem_t sem; int main(void) { pthread_t th1, th2; void* arg; sem_init(&sem, 0, 0); pthread_create(&th1, NULL, PrintHelp, arg); pthread_create(&th2, NULL, PrintHelp2, arg); pthread_join(th2, NULL); pthread_join(th1, NULL); sem_destroy(&sem); return 0; } void* PrintHelp(void* nothing) { sem_wait(&sem); printf("print help...\n"); return 0; } void* PrintHelp2(void* nothing) { getchar(); printf("Print2Ended\n"); sem_post(&sem); return 0; }
신고
TAG
Posted by Kwang-sung Jun