Click here to Skip to main content
15,888,527 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
In a dialog based application,I m having 2 threads one for reading a block from file1 and another for writing the block read from file1 into file2.
The fopen()for *fp and *fpout for reading and writing file respectively defined in InitDialog().
The 2nd thread is not writing anything but file is created as it is in InitDialog().But if fopen *fpout for the file2 is in thread2 it is writing???
Is the file ptr needs to open again and again for thread writing????
Posted

sksksksksksksks wrote:
The fopen()for *fp and *fpout for reading


I thought you said you were using C++, not C ?
 
Share this answer
 
If you have one thread for reading from an input file and a second thread for writing to an output file, it seems to me that having the thread that handles the file be the one that is responsible for opening and closing it makes sense.

Since you are splitting the handling of the output file between the threads, it seems to me that there are 2 obvious potential trouble spots.

1) Is the valid FILE * from the 1st thread being correctly communicated to the second thread?

2) Are there any synchronization problems concerning handling the output file between the two threads?
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900