public void run() {
        //Clear packets from the outgoingBuffer n times per second.
        long timeBetweenTicks = 1000/tickRate;

        while (true){
            // Timer to limit send interval
            long sendAt = System.currentTimeMillis() + timeBetweenTicks;
            while(System.currentTimeMillis() < sendAt){
                // Do nothing.
            }

            // Build a serialiazable packet
            ActionPacket bufferContents[] = server.outgoingBuffer.toArray(new ActionPacket[server.outgoingBuffer.size()]);

            // Backup the actions and send clear the buffer.
            server.allActions.addAll(server.outgoingBuffer);
            server.outgoingBuffer.clear();

            Enumeration enum_clients = server.clients.elements();
            while (enum_clients.hasMoreElements()){
                MazewarServerClient client = (MazewarServerClient)enum_clients.nextElement();

                try {
                    for(int i = 0; i <bufferContents.length; i++){
                        client.sendObject(bufferContents[i]);
                        System.out.println(">>>"+client.name);
                    }
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }

            if (bufferContents.length != 0) {
                System.out.println("Sending "+ bufferContents.length +" packets from buffer to "+ server.clients.size() +" clients.");
            }
        }
    }