Hi,
Threads are running simultaneously and writing to the same file. When two threads write to the file in same time, The code will crash.
Is there any way to organize the writing without using temporary variables?
Hi,
Threads are running simultaneously and writing to the same file. When two threads write to the file in same time, The code will crash.
Is there any way to organize the writing without using temporary variables?
Learn about mutexes
Create an object that serializes the file access using a QMutex. Your threads can then access a single instance of that object.
Horse sense is the thing that keeps horses from betting on people. --W.C. Fields
Ask Smart Questions
Thanks tbscope ,Thanks franz
may I ask for an example.
Thanks in advance for your fast response.
You may.
Note that it will go a lot faster if you search for yourself in the documentation first:
http://doc.qt.nokia.com/4.7/all-examples.html
Then you will find things like this:
http://doc.qt.nokia.com/4.7/threads-waitconditions.
Malek (27th December 2010)
Bookmarks