This week's giveaway is in the EJB and other Java EE Technologies forum. We're giving away four copies of EJB 3 in Action and have Debu Panda, Reza Rahman, Ryan Cuprak, and Michael Remijan on-line! See this thread for details.
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?
Thanks<br />Karthik<br />SCJP 1.4, CCNA.<br /> <br />"Success is relative. More the success, more the relatives."
Well, you probably have not sychronized appropriate pieces of code, otherwise it would work. You are giving us not enough information to help you though... Also, the Threads and Synchronization forum may be a more appropriate place for this. - Peter
Joined: Dec 22, 2002
Thanks!!! I was trying to explain the problem to u, when i found some minor problem. It wasnt exactly due to synchronization, still i corrected it and it works. I'll get back if i see any problem of the same kind again. Thanks again.