java.nio.channels

Class Selector

public abstract class Selector extends Object

Since: 1.4

Constructor Summary
protected Selector()
Initializes the selector.
Method Summary
abstract voidclose()
Closes the selector.
abstract booleanisOpen()
Tells whether the selector is open or not.
abstract Set<SelectionKey>keys()
Returns this selector's key set.
static Selectoropen()
Opens a selector.
abstract SelectorProviderprovider()
Returns the SelectorProvider that created the selector.
abstract intselect()
Selects a set of keys whose corresponding channels are ready for I/O operations.
abstract intselect(long timeout)
Selects a set of keys whose corresponding channels are ready for I/O operations.
abstract Set<SelectionKey>selectedKeys()
Returns this selector's selected-key set.
abstract intselectNow()
Selects a set of keys whose corresponding channels are ready for I/O operations.
abstract Selectorwakeup()
Causes the first selection operation that has not yet returned to return immediately.

Constructor Detail

Selector

protected Selector()
Initializes the selector.

Method Detail

close

public abstract void close()
Closes the selector.

Throws: IOException If an error occurs

isOpen

public abstract boolean isOpen()
Tells whether the selector is open or not.

keys

public abstract Set<SelectionKey> keys()
Returns this selector's key set.

Throws: ClosedSelectorException If this selector is closed.

open

public static Selector open()
Opens a selector.

Throws: IOException If an error occurs

provider

public abstract SelectorProvider provider()
Returns the SelectorProvider that created the selector.

select

public abstract int select()
Selects a set of keys whose corresponding channels are ready for I/O operations.

Throws: ClosedSelectorException If this selector is closed. IOException If an error occurs

select

public abstract int select(long timeout)
Selects a set of keys whose corresponding channels are ready for I/O operations.

Parameters: timeout The timeout to use.

Throws: ClosedSelectorException If this selector is closed. IllegalArgumentException If the timeout value is negative. IOException If an error occurs

selectedKeys

public abstract Set<SelectionKey> selectedKeys()
Returns this selector's selected-key set.

Throws: ClosedSelectorException If this selector is closed.

selectNow

public abstract int selectNow()
Selects a set of keys whose corresponding channels are ready for I/O operations.

Throws: ClosedSelectorException If this selector is closed. IOException If an error occurs

wakeup

public abstract Selector wakeup()
Causes the first selection operation that has not yet returned to return immediately.