1/* Licensed to the Apache Software Foundation (ASF) under one or more 2 * contributor license agreements. See the NOTICE file distributed with 3 * this work for additional information regarding copyright ownership. 4 * The ASF licenses this file to You under the Apache License, Version 2.0 5 * (the "License"); you may not use this file except in compliance with 6 * the License. You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17package java.nio.channels; 18 19import java.io.IOException; 20 21/** 22 * Channels that implement this interface can be asynchronously closed and 23 * interrupted. 24 * <p> 25 * A channel that can be asynchronously closed permits that a thread blocked on 26 * an I/O operation (the I/O thread) can be released by another thread calling 27 * the channel's {@link #close()} method. The I/O thread will throw an 28 * {@link AsynchronousCloseException} and the channel will be closed. 29 * <p> 30 * A channel that is interruptible permits a thread blocked on an I/O operation 31 * (the I/O thread) to be interrupted by another thread (by invoking 32 * {@link Thread#interrupt()} on the I/O thread). When the I/O thread is 33 * interrupted it will throw a {@link ClosedByInterruptException}, it will have 34 * its interrupted status set and the channel will be closed. If the I/O thread 35 * attempts to make an I/O call with the interrupt status set the call will 36 * immediately fail with a {@link ClosedByInterruptException}. 37 */ 38public interface InterruptibleChannel extends Channel { 39 40 /** 41 * Closes the channel. 42 * <p> 43 * Any threads that are blocked on I/O operations on this channel will be 44 * interrupted with an {@link AsynchronousCloseException}. Otherwise, this 45 * method behaves the same as defined in the {@code Channel} interface. 46 * 47 * @throws IOException 48 * if an I/O error occurs while closing the channel. 49 */ 50 public void close() throws IOException; 51} 52