private static synchronized void broadcast(final String message) {

        SwingUtilities.invokeLater(new Runnable() {
            @Override
            public void run() {
                String messageK = message + "\n";

                if (gui != null) {
                    gui.appendRoom(messageK);
                    logChat(messageK);
                } else {
                    System.out.println(messageK);
                }

                for (int i = clientList.size(); --i >= 0; ) {
                    ClientThread ct = clientList.get(i);
                    if (!ct.writeMsg(messageK)) {
                        clientList.remove(i);
                        display("Disconnected client: " + ct.username + " removed from the list.");
                    }
                }

            }
        });


    }