Code example for SelectionKey

Methods: attachment

0
            e.printStackTrace();
        } 
    } 
 
    void dispatch(SelectionKey k) {
        Runnable r = (Runnable) k.attachment();
        if (r != null) {
            r.run();
        } 
    } 
 
    class Acceptor implements Runnable {
        @Override 
        public void run() { 
            try { 
                SocketChannel accept = serverSocketChannel.accept();
                if (null != accept) {
                    //                new Handler(selector,accept); 
                } 
            } catch (IOException e) {
                e.printStackTrace();