List of usage examples for java.nio.channels Selector wakeup
public abstract Selector wakeup();
From source file:org.sonews.daemon.sync.SynchronousNNTPDaemon.java
public static SelectionKey registerSelector(final Selector selector, final SocketChannel channel, final int op) throws CancelledKeyException, ClosedChannelException { // Register the selector at the channel, so that it will be notified // on the socket's events synchronized (RegisterGate) { // Wakeup the currently blocking reader/writer thread; we have // locked the RegisterGate to prevent the awakened thread to block again selector.wakeup(); // Lock the selector to prevent the waiting worker threads going // into selector.select() which would block the selector. synchronized (selector) { return channel.register(selector, op, null); }// www . jav a2s. co m } }
From source file:com.alibaba.napoli.gecko.core.nio.impl.Reactor.java
final void wakeup() { if (this.wakenUp.compareAndSet(false, true)) { final Selector selector = this.selector; if (selector != null) { selector.wakeup(); }//from www. j av a2 s . c o m } }