author | erikj |
Tue, 12 Sep 2017 19:03:39 +0200 | |
changeset 47216 | 71c04702a3d5 |
parent 32143 | jdk/src/java.base/share/classes/java/nio/channels/InterruptibleChannel.java@394ab6a6658d |
permissions | -rw-r--r-- |
2 | 1 |
/* |
5506 | 2 |
* Copyright (c) 2001, Oracle and/or its affiliates. All rights reserved. |
2 | 3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 |
* |
|
5 |
* This code is free software; you can redistribute it and/or modify it |
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
|
5506 | 7 |
* published by the Free Software Foundation. Oracle designates this |
2 | 8 |
* particular file as subject to the "Classpath" exception as provided |
5506 | 9 |
* by Oracle in the LICENSE file that accompanied this code. |
2 | 10 |
* |
11 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
|
12 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
13 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
14 |
* version 2 for more details (a copy is included in the LICENSE file that |
|
15 |
* accompanied this code). |
|
16 |
* |
|
17 |
* You should have received a copy of the GNU General Public License version |
|
18 |
* 2 along with this work; if not, write to the Free Software Foundation, |
|
19 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
|
20 |
* |
|
5506 | 21 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
22 |
* or visit www.oracle.com if you need additional information or have any |
|
23 |
* questions. |
|
2 | 24 |
*/ |
25 |
||
26 |
/* |
|
27 |
*/ |
|
28 |
||
29 |
package java.nio.channels; |
|
30 |
||
31 |
import java.io.IOException; |
|
32 |
||
33 |
||
34 |
/** |
|
35 |
* A channel that can be asynchronously closed and interrupted. |
|
36 |
* |
|
37 |
* <p> A channel that implements this interface is <i>asynchronously |
|
38 |
* closeable:</i> If a thread is blocked in an I/O operation on an |
|
39 |
* interruptible channel then another thread may invoke the channel's {@link |
|
40 |
* #close close} method. This will cause the blocked thread to receive an |
|
41 |
* {@link AsynchronousCloseException}. |
|
42 |
* |
|
43 |
* <p> A channel that implements this interface is also <i>interruptible:</i> |
|
44 |
* If a thread is blocked in an I/O operation on an interruptible channel then |
|
45 |
* another thread may invoke the blocked thread's {@link Thread#interrupt() |
|
46 |
* interrupt} method. This will cause the channel to be closed, the blocked |
|
47 |
* thread to receive a {@link ClosedByInterruptException}, and the blocked |
|
48 |
* thread's interrupt status to be set. |
|
49 |
* |
|
50 |
* <p> If a thread's interrupt status is already set and it invokes a blocking |
|
51 |
* I/O operation upon a channel then the channel will be closed and the thread |
|
52 |
* will immediately receive a {@link ClosedByInterruptException}; its interrupt |
|
53 |
* status will remain set. |
|
54 |
* |
|
55 |
* <p> A channel supports asynchronous closing and interruption if, and only |
|
56 |
* if, it implements this interface. This can be tested at runtime, if |
|
32143
394ab6a6658d
8133459: replace <tt> tags (obsolete in html5) in java.nio docs
avstepan
parents:
25859
diff
changeset
|
57 |
* necessary, via the {@code instanceof} operator. |
2 | 58 |
* |
59 |
* |
|
60 |
* @author Mark Reinhold |
|
61 |
* @author JSR-51 Expert Group |
|
62 |
* @since 1.4 |
|
63 |
*/ |
|
64 |
||
65 |
public interface InterruptibleChannel |
|
66 |
extends Channel |
|
67 |
{ |
|
68 |
||
69 |
/** |
|
70 |
* Closes this channel. |
|
71 |
* |
|
72 |
* <p> Any thread currently blocked in an I/O operation upon this channel |
|
73 |
* will receive an {@link AsynchronousCloseException}. |
|
74 |
* |
|
75 |
* <p> This method otherwise behaves exactly as specified by the {@link |
|
76 |
* Channel#close Channel} interface. </p> |
|
77 |
* |
|
78 |
* @throws IOException If an I/O error occurs |
|
79 |
*/ |
|
80 |
public void close() throws IOException; |
|
81 |
||
82 |
} |