• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

ObjectOutputStream thread issue

 
Hunter McMillen
Ranch Hand
Posts: 492
Firefox Browser Linux VI Editor
  • Mark post as helpful
  • send pies
  • 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.
 
Andrey Kozhanov
Ranch Hand
Posts: 79
  • Mark post as helpful
  • send pies
  • 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().
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic