File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Java in General and the fly likes Threading issue Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "Threading issue" Watch "Threading issue" New topic
Author

Threading issue

Karthik Veeramani
Ranch Hand

Joined: Dec 22, 2002
Posts: 132
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."
Peter den Haan
author
Ranch Hand

Joined: Apr 20, 2000
Posts: 3252
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
Karthik Veeramani
Ranch Hand

Joined: Dec 22, 2002
Posts: 132
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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Threading issue