I just want to implement the code like below.
QString Class1::getNonce()
{
//if some thread is getting nonce wait here until it finishes the its own job.
mutex.lock();
QString nonce=QString("%1").arg(QDateTime::currentDateTime().toTime_t());
mutex.unlock();
return nonce;
}
even I write with mutex different threads get same nonce. How can I solve this problem? Thanks.
I prefer the use of a
QMutexLocker
.Hope that helps.