private void initializeThread() {
        Thread outputter = new Thread(new Runnable() {
            @Override
            public void run() {
                while (true) {
                    String message = packetFactory.receiveMessage().trim();
                    if (message.startsWith("/m/")) {
                        message = message.replace("/m/", "");
                    }
                    log(message);
                }
            }
        });
        outputter.start();

        addWindowListener(new WindowAdapter() {
            @Override
            public void windowClosing(WindowEvent we) {
                packetFactory.sendMessage("/dc/" + username);
                System.exit(0);
            }
        });
    }