diff --git a/notes/生産者消費者/pthread_cc b/notes/生産者消費者/pthread_cc new file mode 100644 index 00000000..2a7a8892 --- /dev/null +++ b/notes/生産者消費者/pthread_cc @@ -0,0 +1,31 @@ +#include +#include +#include + +#define NUM_THREADS 5 + +void *PrintHello(void *threadid) +{ + long tid; + tid = (long)threadid; + printf("Hello World! It's me, thread #%ld!\n", tid); + pthread_exit(NULL); +} + +int main (int argc, char *argv[]) +{ + pthread_t threads[NUM_THREADS]; + int rc; + long t; + for(t=0; t