KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > java > nio > channels > InterruptibleChannel


1 /*
2  * Copyright 2004 Sun Microsystems, Inc. All rights reserved.
3  * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
4  */

5
6 /*
7  * @(#)InterruptibleChannel.java 1.5 03/12/19
8  */

9
10 package java.nio.channels;
11
12 import java.io.IOException JavaDoc;
13
14
15 /**
16  * A channel that can be asynchronously closed and interrupted.
17  *
18  * <p> A channel that implements this interface is <i>asynchronously
19  * closeable:</i> If a thread is blocked in an I/O operation on an
20  * interruptible channel then another thread may invoke the channel's {@link
21  * #close close} method. This will cause the blocked thread to receive an
22  * {@link AsynchronousCloseException}.
23  *
24  * <p> A channel that implements this interface is also <i>interruptible:</i>
25  * If a thread is blocked in an I/O operation on an interruptible channel then
26  * another thread may invoke the blocked thread's {@link Thread#interrupt()
27  * interrupt} method. This will cause the channel to be closed, the blocked
28  * thread to receive a {@link ClosedByInterruptException}, and the blocked
29  * thread's interrupt status to be set.
30  *
31  * <p> If a thread's interrupt status is already set and it invokes a blocking
32  * I/O operation upon a channel then the channel will be closed and the thread
33  * will immediately receive a {@link ClosedByInterruptException}; its interrupt
34  * status will remain set.
35  *
36  * <p> A channel supports asynchronous closing and interruption if, and only
37  * if, it implements this interface. This can be tested at runtime, if
38  * necessary, via the <tt>instanceof</tt> operator.
39  *
40  *
41  * @author Mark Reinhold
42  * @author JSR-51 Expert Group
43  * @version 1.5, 03/12/19
44  * @since 1.4
45  */

46
47 public interface InterruptibleChannel
48     extends Channel JavaDoc
49 {
50
51     /**
52      * Closes this channel.
53      *
54      * <p> Any thread currently blocked in an I/O operation upon this channel
55      * will receive an {@link AsynchronousCloseException}.
56      *
57      * <p> This method otherwise behaves exactly as specified by the {@link
58      * Channel#close Channel} interface. </p>
59      *
60      * @throws IOException If an I/O error occurs
61      */

62     public void close() throws IOException JavaDoc;
63
64 }
65
Popular Tags