43 * handling I/O events, the pooled threads may also execute other tasks required
44 * to support the execution of asynchronous I/O operations.
45 *
46 * <p> An asynchronous channel group is created by invoking the {@link
47 * #withFixedThreadPool withFixedThreadPool} or {@link #withCachedThreadPool
48 * withCachedThreadPool} methods defined here. Channels are bound to a group by
49 * specifying the group when constructing the channel. The associated thread
50 * pool is <em>owned</em> by the group; termination of the group results in the
51 * shutdown of the associated thread pool.
52 *
53 * <p> In addition to groups created explicitly, the Java virtual machine
54 * maintains a system-wide <em>default group</em> that is constructed
55 * automatically. Asynchronous channels that do not specify a group at
56 * construction time are bound to the default group. The default group has an
57 * associated thread pool that creates new threads as needed. The default group
58 * may be configured by means of system properties defined in the table below.
59 * Where the {@link java.util.concurrent.ThreadFactory ThreadFactory} for the
60 * default group is not configured then the pooled threads of the default group
61 * are {@link Thread#isDaemon daemon} threads.
62 *
63 * <table border summary="System properties">
64 * <tr>
65 * <th>System property</th>
66 * <th>Description</th>
67 * </tr>
68 * <tr>
69 * <td> {@code java.nio.channels.DefaultThreadPool.threadFactory} </td>
70 * <td> The value of this property is taken to be the fully-qualified name
71 * of a concrete {@link java.util.concurrent.ThreadFactory ThreadFactory}
72 * class. The class is loaded using the system class loader and instantiated.
73 * The factory's {@link java.util.concurrent.ThreadFactory#newThread
74 * newThread} method is invoked to create each thread for the default
75 * group's thread pool. If the process to load and instantiate the value
76 * of the property fails then an unspecified error is thrown during the
77 * construction of the default group. </td>
78 * </tr>
79 * <tr>
80 * <td> {@code java.nio.channels.DefaultThreadPool.initialSize} </td>
81 * <td> The value of the {@code initialSize} parameter for the default
82 * group (see {@link #withCachedThreadPool withCachedThreadPool}).
83 * The value of the property is taken to be the {@code String}
84 * representation of an {@code Integer} that is the initial size parameter.
85 * If the value cannot be parsed as an {@code Integer} it causes an
86 * unspecified error to be thrown during the construction of the default
87 * group. </td>
88 * </tr>
89 * </table>
90 *
91 * <a id="threading"></a><h2>Threading</h2>
92 *
93 * <p> The completion handler for an I/O operation initiated on a channel bound
94 * to a group is guaranteed to be invoked by one of the pooled threads in the
95 * group. This ensures that the completion handler is run by a thread with the
96 * expected <em>identity</em>.
97 *
98 * <p> Where an I/O operation completes immediately, and the initiating thread
99 * is one of the pooled threads in the group then the completion handler may
100 * be invoked directly by the initiating thread. To avoid stack overflow, an
101 * implementation may impose a limit as to the number of activations on the
102 * thread stack. Some I/O operations may prohibit invoking the completion
103 * handler directly by the initiating thread (see {@link
104 * AsynchronousServerSocketChannel#accept(Object,CompletionHandler) accept}).
105 *
106 * <a id="shutdown"></a><h2>Shutdown and Termination</h2>
107 *
108 * <p> The {@link #shutdown() shutdown} method is used to initiate an <em>orderly
|
43 * handling I/O events, the pooled threads may also execute other tasks required
44 * to support the execution of asynchronous I/O operations.
45 *
46 * <p> An asynchronous channel group is created by invoking the {@link
47 * #withFixedThreadPool withFixedThreadPool} or {@link #withCachedThreadPool
48 * withCachedThreadPool} methods defined here. Channels are bound to a group by
49 * specifying the group when constructing the channel. The associated thread
50 * pool is <em>owned</em> by the group; termination of the group results in the
51 * shutdown of the associated thread pool.
52 *
53 * <p> In addition to groups created explicitly, the Java virtual machine
54 * maintains a system-wide <em>default group</em> that is constructed
55 * automatically. Asynchronous channels that do not specify a group at
56 * construction time are bound to the default group. The default group has an
57 * associated thread pool that creates new threads as needed. The default group
58 * may be configured by means of system properties defined in the table below.
59 * Where the {@link java.util.concurrent.ThreadFactory ThreadFactory} for the
60 * default group is not configured then the pooled threads of the default group
61 * are {@link Thread#isDaemon daemon} threads.
62 *
63 * <table class="altrows">
64 * <caption style="display:none:">System properties</caption>
65 * <thead>
66 * <tr>
67 * <th>System property</th>
68 * <th>Description</th>
69 * </tr>
70 * </thead>
71 * <tbody>
72 * <tr>
73 * <td> {@code java.nio.channels.DefaultThreadPool.threadFactory} </td>
74 * <td> The value of this property is taken to be the fully-qualified name
75 * of a concrete {@link java.util.concurrent.ThreadFactory ThreadFactory}
76 * class. The class is loaded using the system class loader and instantiated.
77 * The factory's {@link java.util.concurrent.ThreadFactory#newThread
78 * newThread} method is invoked to create each thread for the default
79 * group's thread pool. If the process to load and instantiate the value
80 * of the property fails then an unspecified error is thrown during the
81 * construction of the default group. </td>
82 * </tr>
83 * <tr>
84 * <td> {@code java.nio.channels.DefaultThreadPool.initialSize} </td>
85 * <td> The value of the {@code initialSize} parameter for the default
86 * group (see {@link #withCachedThreadPool withCachedThreadPool}).
87 * The value of the property is taken to be the {@code String}
88 * representation of an {@code Integer} that is the initial size parameter.
89 * If the value cannot be parsed as an {@code Integer} it causes an
90 * unspecified error to be thrown during the construction of the default
91 * group. </td>
92 * </tr>
93 * </tbody>
94 * </table>
95 *
96 * <a id="threading"></a><h2>Threading</h2>
97 *
98 * <p> The completion handler for an I/O operation initiated on a channel bound
99 * to a group is guaranteed to be invoked by one of the pooled threads in the
100 * group. This ensures that the completion handler is run by a thread with the
101 * expected <em>identity</em>.
102 *
103 * <p> Where an I/O operation completes immediately, and the initiating thread
104 * is one of the pooled threads in the group then the completion handler may
105 * be invoked directly by the initiating thread. To avoid stack overflow, an
106 * implementation may impose a limit as to the number of activations on the
107 * thread stack. Some I/O operations may prohibit invoking the completion
108 * handler directly by the initiating thread (see {@link
109 * AsynchronousServerSocketChannel#accept(Object,CompletionHandler) accept}).
110 *
111 * <a id="shutdown"></a><h2>Shutdown and Termination</h2>
112 *
113 * <p> The {@link #shutdown() shutdown} method is used to initiate an <em>orderly
|