Selects a set of keys whose corresponding channels are ready for I/O operations.
This method performs a blocking selection operation. It returns only after at least one channel is selected, this selector's {@link #wakeup wakeup} method is invoked, the currentthread is interrupted, or the given timeout period expires, whichever comes first.
This method does not offer real-time guarantees: It schedules the timeout as if by invoking the {@link Object#wait(long)} method.
@param timeout If positive, block for up to
timeoutmilliseconds, more or less, while waiting for a channel to become ready; if zero, block indefinitely; must not be negative
@return The number of keys, possibly zero,whose ready-operation sets were updated
@throws IOException If an I/O error occurs
@throws ClosedSelectorException If this selector is closed
@throws IllegalArgumentException If the value of the timeout argument is negative