From f9b4307a9d436236ead6bb0a599fdfdc3ca5eaa9 Mon Sep 17 00:00:00 2001 From: JustinMcLain1 <70154173+JustinMcLain1@users.noreply.github.com> Date: Wed, 1 Jun 2022 15:06:40 -0500 Subject: [PATCH] Create pthread_cc --- notes/生産者消費者/pthread_cc | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 notes/生産者消費者/pthread_cc 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