@Override
    public void run() {
        active = true;
        while (keepRunning && !Thread.interrupted()) {
            synchronized (guardlock) {
                // Wait for the lock on the selector key-set before continuing
            }
            try {
                int eventCount = selector.select(clientTimeout);
                if (eventCount == 0) {
                    // TODO: Check for timed out clients and reap them.
                    continue;
                }
                Iterator<SelectionKey> it = selector.selectedKeys().iterator();
                while (it.hasNext()) {
                    SelectionKey key = it.next();
                    it.remove();
                    if (key.isReadable()) {
                        processReadReady(key);
                    } else if (key.isWritable()) {
                        processWriteReady(key);
                    }
                }
            } catch (IOException e) {
            	LOGGER.log(new WorkerLogRecord(this, 
            			String.format("Failed to select anything in worker %s.", identifier), e));
            }
        }
        closeWorker();
        active = false;
    }