static void *GoSubwayGo(void *index) { clock_t start, stop; double diff; int Subway; int Status; int GotThere = 1; Subway = atoi((char*) index); printf("Subway %d started\n", Subway+1); while (GotThere != 0) { printf("Subway: %d\n", Subway+1); start = clock(); diff = difftime(stop = clock(), start); if((Status = pthread_mutex_lock(&mutex)) != 0); { fprintf(stderr,"%s: Error Mutex_Lock\n", pProgname); exit(EXIT_FAILURE); } if(value.nNowDistance[Subway] >= value.nSpeed[Subway]) { value.nNowDistance[Subway] = value.nNowDistance[Subway] - value.nSpeed[Subway]; } else value.nNowDistance[Subway] = 0; GotThere = value.nNowDistance[Subway]; if((Status =pthread_mutex_unlock(&mutex)) != 0) { fprintf(stderr,"%s: Error Mutex_Unlock\n", pProgname); exit(EXIT_FAILURE); } } pthread_exit((void *) 0); }