Async channels
Rémi Forax
forax at univ-mlv.fr
Tue Apr 21 14:29:03 PDT 2009
Alan Bateman a écrit :
[...]
>> Taking an Executor an not a AsyncChannelGroup doesn't prevent sharing.
>> Currently, you can write:
>>
>> ExecutorService executor=Executors.newCachedThreadPool();
>> AsynchronousChannelGroup channelGroup =
>> AsynchronousChannelGroup.withThreadPool(executor);
>> AsynchronousServerSocketChannel serverSocketChannel =
>> AsynchronousServerSocketChannel.open(channelGroup);
>> AsynchronousFileChannel fileChannel =
>> AsynchronousFileChannel.open(path, openOptions, executor);
> You could but this goes against the warning in the spec that the
> thread pool is intended to be used exclusively by the resulting group.
I think I don't understand the difference between an Executor and a
AsyncChannelGroup.
Furthermore, there is currently no way to use the same Executor for more
that one
AsyncFileChannel because closing the file channel will shutdown the
executor.
I don't understand the purpose of this restriction.
[...]
>
>
> -Alan.
Rémi
More information about the nio-dev
mailing list