스콧 마이어스 EC++ 공부하면서 pthread_mutex_lock/unlock 사용하는 프로그램 짜보고 있는데, 책 대로라면 원래 필요없을 unLock()함수를 사용해야만 제대로 동작하는 듯 합니다.
뭐가 문제인지 모르겠네요. 조언 부탁 드립니다...
// g++ test.cpp -o test -lpthread
// kdlp 게시판에 <<>>가 안먹어서 아래에는 생략
#include iostream
#include stdlib.h
#include pthread.h
#include exception
using namespace std;
#define NUM_THREADS 2
#define RUN_TIME 20
bool thread1_run = true;
bool thread2_run = true;
pthread_mutex_t *mutex;
int shared_data = 0;