@Override
        public void run() {
            try {           
                running = true;
                runLoop();
                if(log.isLoggable(Level.FINE))
                    log.fine("shutting down the PollingThread");
                selector.close();
                selector = null;
                thread = null;                

                synchronized(SelectorImpl.this) {
                    running = false;
                    SelectorImpl.this.notifyAll();
                }
            } catch (Exception e) {
                log.log(Level.WARNING, id+"Exception on ConnectionManager thread", e);
            }
        }
    }
    
    protected void runLoop() {
        while (!wantToShutDown) {
            listener.selectorFired();
        }
    }

    /**
     * @see org.playorm.nio.api.testutil.nioapi.Select#getThread()
     */
    public Object getThread() {
        return thread;
    }

    /**
     * @see org.playorm.nio.api.testutil.nioapi.Select#selectedKeys()
     */
    public Set<SelectionKey> selectedKeys() {
        return selector.selectedKeys();
    }

    /**
     * @throws IOException 
     * @see org.playorm.nio.api.testutil.nioapi.Select#select()
     */
    public int select() throws IOException {
        return selector.select();
    }

    /**
     * @see org.playorm.nio.api.testutil.nioapi.Select#isRunning()
     */
    public boolean isRunning() {
        return running;
    }

    /**
     * @see org.playorm.nio.api.testutil.nioapi.Select#isWantShutdown()
     */
    public boolean isWantShutdown() {
        return wantToShutDown;
    }

    /**
     * @see org.playorm.nio.api.testutil.nioapi.Select#setRunning(boolean)
     */
    public void setRunning(boolean b) {
        running = b;
    }

    /**
     * @see org.playorm.nio.api.testutil.nioapi.Select#createRegistrationListener
     * (java.lang.Object, org.playorm.nio.api.testutil.nioapi.SelectorRunnable, org.playorm.nio.impl.cm.basic.SelectorManager2)
     */
    public ChannelRegistrationListener createRegistrationListener(Object id, SelectorRunnable r, Object s) {
        return new RegistrationListenerImpl(id, r, (SelectorManager2)s);
    }

    /**
     * @see org.playorm.nio.api.testutil.nioapi.Select#getKeyFromChannel(java.nio.channels.SelectableChannel)
     */
    public SelectionKey getKeyFromChannel(SelectableChannel realChannel) {
        return realChannel.keyFor(selector);
    }