fprintf(stderr, "PR_WaitSemaphore failed\n");
fprintf(stderr, "PR_PostSemaphore failed\n");
void ThreadFunc(void *arg){    PRIntn i;    for (i = 0; i < iterations; i++) {        if (PR_WaitSemaphore(sem2) == PR_FAILURE) {            fprintf(stderr, "PR_WaitSemaphore failed\n");            exit(1);        }        if (counter == 2*i+1) {            if (debug_mode) printf("thread 2: counter = %d\n", counter);        } else {            fprintf(stderr, "thread 2: counter should be %d but is %d\n",                    2*i+1, counter);            exit(1);        }        counter++;        if (PR_PostSemaphore(sem1) == PR_FAILURE) {            fprintf(stderr, "PR_WaitSemaphore failed\n");            exit(1);        }    }}