public class AsyncSelector extends Object implements Runnable
To close async selector, close its selector (getSelector().close()).
AsyncSelector guarantees that selection event of a key is handled in one thread at a time, and it the event handled accordingly, new selection events do not occur.
| Modifier and Type | Class and Description |
|---|---|
static class |
AsyncSelector.Interests
An internal enum for modelling
SelectionKey interestops. |
static interface |
AsyncSelector.SelectListener |
| Constructor and Description |
|---|
AsyncSelector()
Construct AsyncSelector with brand new selector
|
AsyncSelector(Selector sel)
Construct new AsyncSelector
|
| Modifier and Type | Method and Description |
|---|---|
void |
close()
close.
|
Selector |
getSelector()
getSelector.
|
void |
interestOps(SelectableChannel channel,
int interestOps)
Modify interest ops of a key.
|
void |
register(SelectableChannel channel,
int ops,
AsyncSelector.SelectListener selectEventListener)
Register a selection event handler to a selectable channel.
|
void |
run() |
void |
unregister(SelectableChannel channel)
unregister.
|
public AsyncSelector()
throws IOException
IOException - if any.public AsyncSelector(Selector sel) throws IOException
sel - a Selector object.IOException - if any.public void close()
throws IOException
close.
IOException - if any.public void interestOps(SelectableChannel channel, int interestOps) throws CancelledKeyException
channel - registered keyinterestOps - new interest op setCancelledKeyException - if any.public void register(SelectableChannel channel, int ops, AsyncSelector.SelectListener selectEventListener) throws ClosedChannelException
selectEventListener is invoked by one thread at a time. The rule of thumb is that the listener must not block. Note! If channel is registered and closed, select event is invoked until the channel is unregistered.
channel - a SelectableChannel object.ops - initial interest ops See SelectionKeyselectEventListener - a
AsyncSelector.SelectListener object.ClosedChannelException - if any.public void unregister(SelectableChannel channel)
unregister.
channel - a SelectableChannel object.Copyright © 2026. All rights reserved.