879653 wrote:Why? Have you measured it and determined that it does not meet your specific, documented requirements?
What I want is to improve performance.
Now I'm thinking about using a PRODUCER-CONSUMER approach to improve performance, having 1 thread reading data from file and having 1 thread validating data.Using multiple threads may or may not improve performance. The issue you have to consider before you even put multithreading on the table is whether the tasks you're planning to multithread can logically be run independently of each other. Certainly for the most basic form--a single producer thread reading from the file and inserting into the queue and a single consumer thread reading from the queue and processing the data--should be viable. But the next logical step--multiple consumer threads--may not be viable, if processing needs to occur in the same order as reading.
What do you think? Is there a better approach on this kind of problem?I think you haven't really defined an actual problem yet.