#include #include #include #define NUM_THREADS 500 int global = 0; /* Note scope of variable and mutex are the same */ pthread_mutex_t mutex1 = PTHREAD_MUTEX_INITIALIZER; void *PrintHello(void *threadid) { long tid; tid = (long)threadid; pthread_mutex_lock( &mutex1 ); global++; pthread_mutex_unlock( &mutex1 ); //printf("Hello World from thread #%ld\n", tid); // EXIT THREAD } int main (int argc, char *argv[]) { // DECLARE THREADS pthread_t threads[NUM_THREADS]; int rc; long t; void *status; // CREATE MULTIPLE THREADS for(t=0; t