Methods Summary |
---|
public abstract void | close()Closes this selector. Ongoing calls to the {@code select} methods of this
selector will get interrupted. This interruption behaves as if the
{@link #wakeup()} method of this selector is called. After this, all keys
that are still valid are invalidated and their channels are unregistered.
All resources held by this selector are released.
Any further attempt of using this selector after this method has been
called (except calling {@link #close()} or {@link #wakeup()}) results in
a {@link ClosedSelectorException} being thrown.
|
public abstract boolean | isOpen()Indicates whether this selector is open.
|
public abstract java.util.Set | keys()Gets the set of registered keys. The set is immutable and is not thread-
safe.
|
public static java.nio.channels.Selector | open()The factory method for selector. It returns the selector returned by the
default {@link SelectorProvider} by calling its {@code openCollector}
method.
return SelectorProvider.provider().openSelector();
|
public abstract java.nio.channels.spi.SelectorProvider | provider()Gets the provider of this selector.
|
public abstract int | select()Detects if any of the registered channels is ready for I/O operations
according to its {@link SelectionKey interest set}. This method does not
return until at least one channel is ready, {@link #wakeup()} is
invoked or the calling thread is interrupted.
|
public abstract int | select(long timeout)Detects if any of the registered channels is ready for I/O operations
according to its {@link SelectionKey interest set}. This method does not
return until at least one channel is ready, {@link #wakeup()} is invoked,
the calling thread is interrupted or the specified {@code timeout}
expires.
|
public abstract int | selectNow()Detects if any of the registered channels is ready for I/O operations
according to its {@link SelectionKey interest set}. This operation will
return immediately.
|
public abstract java.util.Set | selectedKeys()Gets the selection keys whose channels are ready for operation. The set
is not thread-safe and no keys may be added to it. Removing keys is
allowed.
|
public abstract java.nio.channels.Selector | wakeup()Forces blocked {@code select} operations to return immediately.
If no {@code select} operation is blocked when {@code wakeup()} is called
then the next {@code select} operation will return immediately. This can
be undone by a call to {@code selectNow()}; after calling
{@code selectNow()}, a subsequent call of {@code select} can block
again.
|