Qt4学习笔记(三),QThread学习之QMutex

#include <QMutex>

//临界资源
class Key
{
public:
	Key()
	{
		key = 0;
	}
	int createKey()
	{
		QMutexLocker locker(&mutex);
		++key;
		return key;
	}
	int value()
	{
		QMutexLocker locker(&mutex);
		return key;
	}

private:
	int key;
	QMutex mutex;
}

说明:





猜你喜欢

转载自blog.csdn.net/u012592062/article/details/80289459
qt4
今日推荐