示例#1
0
文件: main.c 项目: Lgggg/wangdaozuoye
void* handle1(void* arg){
	mtx.lock();
	std::cout<<"thread1 before add:"<<cnt<<std::endl;
	cnt++;
	std::cout<<"thread1 after add: "<<cnt<<std::endl;
	mtx.unlock();
	sleep(2);
}
示例#2
0
文件: main.c 项目: Lgggg/wangdaozuoye
void* handle2(void* arg){
	while(1){
	mtx.lock();
	std::cout<<"thread2 before add:"<<cnt<<std::endl;
	cnt++;
	std::cout<<"thread2 after add: "<<cnt<<std::endl;
	mtx.unlock();
	sleep(2);
	}
}