42 import java.nio.channels.*;
54 class DispatcherN
implements Dispatcher {
58 DispatcherN() throws IOException {
59 sel = Selector.open();
66 }
catch (IOException x) {
72 private Object gate =
new Object();
74 private void dispatch() throws IOException {
76 for (Iterator i = sel.selectedKeys().iterator(); i.hasNext(); ) {
77 SelectionKey sk = (SelectionKey)i.next();
79 Handler h = (Handler)sk.attachment();
82 synchronized (gate) { }
85 public void register(SelectableChannel ch,
int ops, Handler h)
89 ch.register(sel, ops, h);