• Post Reply Bookmark Topic Watch Topic
  • New Topic

Vectors and streams

 
bobo shante
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am trying to develop a simple mutlithreaded chat server. The file Server.java contains two classes one is the GUI and the other is a thread which is spawned each time a corresponding client thread is connected to it. I use a JList to show a list of online users and a Vector which stores the names as strings.
Each time a new client connects to a server thread it(the client) passes its username to the server thread which in turn has a refernce to the server frame. Each server thread adds an element to the vector which is a property of the server frame. A method of the server frame then loops through the server threads which are also in a vector and writes the updated Vector(containg the clients' names) to each respective server thread output stream.
My problem is that when the vector is received in the client thread only the last client to connect will have the full quota of names and the others will remain the same as when they were just connected.
I would really appreciate any help!
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!