Hi...
Im doing a multi-threading program using QThread and QMutex for synchronization. my question is.. does QMutex lock all the variable in the between of lock and unlock command?? how about function that being call in the lock range?? can any other thread use the same function or data that being access by the function?? and does pointer to the lock variable also need to take turn to access the lock variable?
sample code..
void somefunction2(int *f);
QMutex Dflag;
(thread one)
Dflag.lock;
x=3; y=4;
somefunction(j,k);
Dflag.unlock;
(thread two)
Dflag.lock;
x=y; y=45;
somefunction(j,k);
Dflag.unlock;
(thread three)
Dflag.lock;
y=*x
somefunction2(l);
Dflag.unlock;
thanks in advance..
p/s: i also do write the value of the variable in .txt using QFile.. and the command is in the lock-unlock code. it is possible to have both thread to write at the same time?? i us QDateTime to keep tracking the time i get the data..
Bookmarks