I have an issue with multi-threading. To brief the problem -
I have 2 classes - say, udpreader and packethandler. I need to read the udp port and do some processing (say write to file). i need a good reading rate, and as i found that reading and processing using the same class isnt that fast, i created 2 classes (and both extend
Thread). the 1st class initially starts the thread of the 2nd class. it reads the port and hands over the messages to 2nd class. In 2nd class, i have a vector to queue the messages, take 1 by 1 and write to file.
Now my problem is, i find that, if i send some 500 messages to udp port (via some other program), the udpreader class seems to read it all, but in the file where i need all the messages (which is written by the packethandler class), i find many messages missing. there isnt any specific order, randomly they r missing, and i find very few messages finally in the file.
I have synchronized appropriate pieces of code. Can any 1 good in threading help me out?