/* This thread tries to lock the mutex to enter the critical section. Then it signals one waiting thread to check the condition and it goes to sleep again If is_finished is set to 1 second_thread ends.  */
static void* second_thread(void *arg)
/* This thread tries to lock the mutex to enter the critical section. Then it signals one waiting thread to check the condition and it goes to sleep again If is_finished is set to 1 second_thread ends.  */
static void* second_thread(void *arg)
{
    (void) arg;
    while (1) {
        mutex_lock(&mutex);
        if (is_finished == 1) {
            break;
        }
        pthread_cond_signal(&cv);
        mutex_unlock_and_sleep(&mutex);
    }
    return NULL;
}