public Server(int port) throws IOException {
        clientList = new ArrayList<ConnectionToClient>();
        messages = new LinkedBlockingQueue<Object>();
        serverSocket = new ServerSocket(port);

        Thread accept = new Thread() {
            public void run() {
                while (true) {
                    try {
                        Socket s = serverSocket.accept();
                        System.out.println("connection "+s);
                        clientList.add(new ConnectionToClient(s));
                    } catch (IOException ex) {
                        Logger.getLogger(Server.class.getName()).log(Level.SEVERE, null, ex);
                    }
                }
            }
        };

        accept.setDaemon(true);
        accept.start();

        Thread messageHandling = new Thread() {
            public void run() {
                while (true) {
                    try {
                        Object message = messages.take();
                        // Do some handling here...
                        if(message instanceof Message){
                            Message m=(Message)message;
                            if(m.getHeader().equals("quit"))
                                running=false;
                            else if(m.getHeader().equals("message")){
                                sendToAll(message);
                            }else if(m.getHeader().equals("file")){
                                sendToAll(message);
                            }
                        }
                    } catch (InterruptedException e) {
                    }
                }
            }
        };

        messageHandling.setDaemon(true);
        messageHandling.start();
    }