i don't really understand the thread in class.
if i have code like this
ServerThread *thread = new ServerThread( descriptor, this );
ServerThread *thread = new ServerThread( descriptor, this );
To copy to clipboard, switch view to plain text mode
so i create the instance of this thread class. in the class I have
priave int ServerThread::num
run{
num ++;
}
thread->start();
priave int ServerThread::num
run{
num ++;
}
thread->start();
To copy to clipboard, switch view to plain text mode
now i create another thread.
ServerThread *thread2 = new ServerThread( descriptor, this );
ServerThread *thread2 = new ServerThread( descriptor, this );
To copy to clipboard, switch view to plain text mode
thread2->start();
in this case. I think that i don't need to protect the variable int num. because they are in different instance, is that right?
Bookmarks