• 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

ObjectOutputStream thread issue

 
Ranch Hand
Posts: 492
Firefox Browser VI Editor Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hey all,

I am writing a small chat server for one of my classes. I am using a multi-threaded client/server model so whenever a client connects a new thread is created to hold the client/server interactions, I am passing data across sockets using ObjectOutputStreams and ObjectInputStreams. I am running into an issue where some of my methods only work for the LAST client that connects, which leads me to believe that I am overwriting data somewhere I just cant seem to find where. I was hoping someone could spot my mistake.

ThreadHandler:


Client:


Sorry for the long post, any ideas would be great!

Thanks.
Hunter.
 
Ranch Hand
Posts: 79
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello!

You didn't provide the full code therefore it's hard to say where the problem is. Also you didn't tell what particular methods does not work as expected. So I can only guess that this might be methods, which calls ChatServer.getClients() and similiar functions, i.e. static functions that return collections. The matter is that returning static Collection instance 'as is' might not work properly. To fix this problem the function should return Collection.clone().
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic