Data lost - Client/Server
<p>I'm trying to write simple online status displayer in JAVA for my communicator Client-Server. When someone connects it shows new member online in my JList. Simple. I have a class called "container" which (as the name suggests) contains reference to List Object and a message object. My list is a simple map, where key is an unique ID for each user and String is his nickname. This map is in List Object as a field. Then, I send this serialized object to a client. The problem is that when I have two clients, first who connects to server see only 1 online (himself) and the second one see both (2 online). It is strange becouse for example when I send only a integer with a numer of online members, both clients see "2" - so it's correct and when I try to print numbers of online clients before sending to client (map.size()) i see "2". So before sending is good but after reading is only "1" (for first client). How is that possible?</p>

<p>Server side:</p>

<pre><code>private void rewrite() {
    online.clear();
    for(int key : handlerMap.keySet()) {
        online.put(handlerMap.get(key).getId(), handlerMap.get(key).getNickname());              
    }     
}

public void run() {
    try {
        ObjectOutputStream oos = new ObjectOutputStream(socket.getOutputStream());
        container = new MsgContainer();
        list = new OnlineList();

        while(!interrupt) {
            rewrite();
            list.setOnlineList(online);
            container.setMessage(message);
            container.setList(list); 
            System.out.println("klucz - "+id+" ----------" 

+container.getList().getOnlineList().size()); //id is an unique id. It shows 2 online `for` 
//1st client and 2 for 2cnd. All ok. But when I send and read on first client's side it `//shows only 1,`
            oos.writeObject(container);
            message = null;
            Thread.sleep(100);
        }
        oos.close();
    } 
    catch(InterruptedException e) { System.out.println(e); }
    catch(IOException e) { System.out.println(e); } 

    threadOnlineList.interrupt();
}
</code></pre>

<p>Client side:</p>

<pre><code>public void run() {
    try {
        ObjectInputStream ois = new ObjectInputStream(socket.getInputStream());
        while(!interrupt) {
            if(ois.readObject() != null) {
                MsgContainer container = (MsgContainer) ois.readObject();
                //updateList(container.getList().getOnlineList());
                System.out.println(container.getList().getOnlineList().size()); 
////shows 
//1 for first client and 2 for second one.
            }
            Thread.sleep(100);
        }
        ois.close();
    } 
    catch(IOException e) { System.out.println(e); }
    catch(InterruptedException e) { System.out.println(e); }
    catch(ClassNotFoundException e) { System.out.println(e); }
}
</code></pre>
