• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Threading issue

 
Ranch Hand
Posts: 132
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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?
 
author
Posts: 3252
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 132
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
You are HERE! The other map is obviously wrong. Better confirm with this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic