# Print output for @column tags ?>
Developers

- Design
- Develop
- Distribute

Developer Console

## Most visited

## Recently visited

## Results for

Summary: Protected Ctors | Methods | Protected Methods | Inherited Methods

# AbstractSelector

`public abstract class AbstractSelector`
`` `extends Selector` ``

java.lang.Object
↳ | java.nio.channels.Selector
| ↳ | java.nio.channels.spi.AbstractSelector

Base implementation class for selectors.

This class encapsulates the low-level machinery required to implement the interruption of selection operations. A concrete selector class must invoke the `begin` and `end` methods before and after, respectively, invoking an I/O operation that might block indefinitely. In order to ensure that the `end` method is always invoked, these methods should be used within a `try` ... `finally` block:

>      try {
>          begin();
>          // Perform blocking I/O operation here
>          ...
>      } finally {
>          end();
>      }

This class also defines methods for maintaining a selector's cancelled-key set and for removing a key from its channel's key set, and declares the abstract `register` method that is invoked by a selectable channel's `register` method in order to perform the actual work of registering a channel.

## Summary

### Protected constructors
`AbstractSelector(SelectorProvider provider)` Initializes a new instance of this class.

### Public methods
`final void` | `close()` Closes this selector.
`final boolean` | `isOpen()` Tells whether or not this selector is open.
`final SelectorProvider` | `provider()` Returns the provider that created this channel.

### Protected methods
`final void` | `begin()` Marks the beginning of an I/O operation that might block indefinitely.
`final Set<SelectionKey>` | `cancelledKeys()` Retrieves this selector's cancelled-key set.
`final void` | `deregister(AbstractSelectionKey key)` Removes the given key from its channel's key set.
`final void` | `end()` Marks the end of an I/O operation that might block indefinitely.
`abstract void` | `implCloseSelector()` Closes this selector.
`abstract SelectionKey` | `register(AbstractSelectableChannel ch, int ops, Object att)` Registers the given channel with this selector.

### Inherited methods
From class `java.nio.channels.Selector`
`abstract void` | `close()` Closes this selector.
`abstract boolean` | `isOpen()` Tells whether or not this selector is open.
`abstract Set<SelectionKey>` | `keys()` Returns this selector's key set.
`static Selector` | `open()` Opens a selector.
`abstract SelectorProvider` | `provider()` Returns the provider that created this channel.
`abstract int` | `select(long timeout)` Selects a set of keys whose corresponding channels are ready for I/O operations.
`abstract int` | `select()` Selects a set of keys whose corresponding channels are ready for I/O operations.
`abstract int` | `selectNow()` 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 Selector` | `wakeup()` Causes the first selection operation that has not yet returned to return immediately.
From class `java.lang.Object`
`Object` | `clone()` Creates and returns a copy of this object.
`boolean` | `equals(Object obj)` Indicates whether some other object is "equal to" this one.
`void` | `finalize()` Called by the garbage collector on an object when garbage collection determines that there are no more references to the object.
`final Class<?>` | `getClass()` Returns the runtime class of this `Object`.
`int` | `hashCode()` Returns a hash code value for the object.
`final void` | `notify()` Wakes up a single thread that is waiting on this object's monitor.
`final void` | `notifyAll()` Wakes up all threads that are waiting on this object's monitor.
`String` | `toString()` Returns a string representation of the object.
`final void` | `wait(long timeout, int nanos)` Causes the current thread to wait until another thread invokes the `notify()` method or the `notifyAll()` method for this object, or some other thread interrupts the current thread, or a certain amount of real time has elapsed.
`final void` | `wait(long timeout)` Causes the current thread to wait until either another thread invokes the `notify()` method or the `notifyAll()` method for this object, or a specified amount of time has elapsed.
`final void` | `wait()` Causes the current thread to wait until another thread invokes the `notify()` method or the `notifyAll()` method for this object.
From interface `java.io.Closeable`
`abstract void` | `close()` Closes this stream and releases any system resources associated with it.
From interface `java.lang.AutoCloseable`
`abstract void` | `close()` Closes this resource, relinquishing any underlying resources.

## Protected constructors

### AbstractSelector

    protected AbstractSelector (SelectorProvider provider)

Initializes a new instance of this class.

Parameters
`provider` | `SelectorProvider`: The provider that created this selector

## Public methods

### close

    public final void close ()

Closes this selector.

If the selector has already been closed then this method returns immediately. Otherwise it marks the selector as closed and then invokes the `implCloseSelector` method in order to complete the close operation.

Throws
`IOException` | If an I/O error occurs

### isOpen

    public final boolean isOpen ()

Tells whether or not this selector is open.

Returns
`boolean` | `true` if, and only if, this selector is open

### provider

    public final SelectorProvider provider ()

Returns the provider that created this channel.

Returns
`SelectorProvider` | The provider that created this channel

## Protected methods

### begin

    protected final void begin ()

Marks the beginning of an I/O operation that might block indefinitely.

This method should be invoked in tandem with the `end` method, using a `try` ... `finally` block as shown above, in order to implement interruption for this selector.

Invoking this method arranges for the selector's `wakeup` method to be invoked if a thread's `interrupt` method is invoked while the thread is blocked in an I/O operation upon the selector.

### cancelledKeys

    protected final Set<SelectionKey> cancelledKeys ()

Retrieves this selector's cancelled-key set.

This set should only be used while synchronized upon it.

Returns
`Set<SelectionKey>` | The cancelled-key set

### deregister

    protected final void deregister (AbstractSelectionKey key)

Removes the given key from its channel's key set.

This method must be invoked by the selector for each channel that it deregisters.

Parameters
`key` | `AbstractSelectionKey`: The selection key to be removed

### end

    protected final void end ()

Marks the end of an I/O operation that might block indefinitely.

This method should be invoked in tandem with the `begin` method, using a `try` ... `finally` block as shown above, in order to implement interruption for this selector.

### implCloseSelector

    protected abstract void implCloseSelector ()

Closes this selector.

This method is invoked by the `close` method in order to perform the actual work of closing the selector. This method is only invoked if the selector has not yet been closed, and it is never invoked more than once.

An implementation of this method must arrange for any other thread that is blocked in a selection operation upon this selector to return immediately as if by invoking the `wakeup` method.

Throws
`IOException` | If an I/O error occurs while closing the selector

### register

    protected abstract SelectionKey register (AbstractSelectableChannel ch,
                    int ops,
                    Object att)

Registers the given channel with this selector.

This method is invoked by a channel's `register` method in order to perform the actual work of registering the channel with this selector.

Parameters
`ch` | `AbstractSelectableChannel`: The channel to be registered
`ops` | `int`: The initial interest set, which must be valid
`att` | `Object`: The initial attachment for the resulting key

Returns
`SelectionKey` | A new key representing the registration of the given channel with this selector

Full name *
Email address *
Company / developer name
One of your Play Store app URLs *
Which best describes your business:*
Apps
Games
Apps & Games
*
*