// Simple program to demonstrate using a mutex lock
// WARNING: this program does not check the return values of system calls

#include <stdlib.h>
#include <pthread.h>
#include <iostream>
using namespace std;

pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER;

void *child(void *arg)
{
    cout << "hello from child, about to wait on mutex_lock\n";
    pthread_mutex_lock(&mutex);
    cout << "child after call to loc\n";
}

int main()
{
    // lock the mutext so child can't get it
    pthread_mutex_lock(&mutex);

    pthread_t thread_id;
    pthread_create(&thread_id, NULL, child, NULL);

    sleep(2);
    pthread_mutex_unlock(&mutex);
    sleep(3);
}

