Static ArrayList does not modify in another class
<p>I am working on a client - server application and I have the following problem.</p>

<p>In one class (Server), I have a static reference to an ArrayList called clients and a static getter getClientsArray(). In another class (ServerThread), I use the same ArrayList and I successfully modify it (add / delete clients). </p>

<p>For every client, I call the method getClientsArray() and get that ArrayList. The problem is that the ArrayList is empty here, in Client class. I check it every time I update it in ServerThread (after a client connects) and it should have something in it.</p>

<pre><code>    public class Server {
            private static ArrayList&lt;User&gt; clients = new ArrayList&lt;User&gt;();

            public static ArrayList&lt;User&gt; getClientsArray() {
                  return clients;
            }

            and somewhere I call: new ServerThread(sock, users).start();
    }

    public class ServerThread extends Thread {
        private ArrayList&lt;User&gt; users;

        public ServerThread(Socket client, ArrayList&lt;User&gt; users) {
                this.client = client;
                this.users = users;
        }
        if I modify users in this class, the changes will occur
    }

    public class Client extends JFrame {
        private ArrayList&lt;User&gt; users;
            public Client() {
                initGraphics();

                users = Server.getClientsArray();
                System.out.println(users.size()); &lt;- This line always writes 0!!    
            }
    }
</code></pre>
