01: /* Licensed to the Apache Software Foundation (ASF) under one or more
02: * contributor license agreements. See the NOTICE file distributed with
03: * this work for additional information regarding copyright ownership.
04: * The ASF licenses this file to You under the Apache License, Version 2.0
05: * (the "License"); you may not use this file except in compliance with
06: * the License. You may obtain a copy of the License at
07: *
08: * http://www.apache.org/licenses/LICENSE-2.0
09: *
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:
17: package java.nio.channels;
18:
19: import java.io.IOException;
20:
21: /**
22: * Channels that implement this interface are both asynchronously closable and
23: * interruptible.
24: * <p>
25: * A channel that is asynchronously closable permits a thread blocked on an IO
26: * operation (the IO thread) to be released by another thread calling the
27: * channel's <code>close()</code> method. The IO thread will throw an
28: * <code>AsynchronousCloseException</code> and the channel will be closed.
29: * </p>
30: * <p>
31: * A channel that is interruptible permits a thread blocked on an IO operation
32: * (the IO thread) to be interrupted by another thread (by invoking
33: * <code>interrupt()</code> on the IO thread). When the IO thread is
34: * interrupted it will throw a <code>ClosedByInterruptException</code>
35: * exception, it will have its interrupted status set, and the channel will be
36: * closed. If the IO thread attempts to make an IO call with the interrupt
37: * status set the call will immediately fail with a
38: * <code>ClosedByInterruptException</code>.
39: */
40: public interface InterruptibleChannel extends Channel {
41:
42: /**
43: * Closes an InterruptibleChannel. This method is precisely the same as the
44: * super-interface <code>close()</code>.
45: * <p>
46: * Any threads that are blocked on IO operations on this channel will be
47: * interrupted with an <code>AsynchronousCloseException
48: * </code>.
49: * </p>
50: *
51: * @throws IOException
52: * if an IO problem occurs closing the channel.
53: */
54: public void close() throws IOException;
55: }
|