I got one class which extends from a Thread class.
In the main process I'm accessing (read and write) a file named "stt.txt" also in the thread (in thread function) I'm accessing the same file (reading n writing).
1. Will this cause an error.
2. And how to perform such a task in C++.
OS: Solaris 10
compiler : gcc 3.4.3
Thread Lib :POSIX Threads <pthread.h>
| QUOTE (kasun04 @ Feb 7 2007, 09:05 AM) |
I got one class which extends from a Thread class. In the main process I'm accessing (read and write) a file named "stt.txt" also in the thread (in thread function) I'm accessing the same file (reading n writing).
1. Will this cause an error. 2. And how to perform such a task in C++. OS: Solaris 10 compiler : gcc 3.4.3 Thread Lib :POSIX Threads <pthread.h> |
As long as you use the same file handel in both threads everything should be OK.
Of course if both threads write at the same time you do not know what order items will be placed in the file.