executor for AsynchronousFileChannel.open()

Alan Bateman Alan.Bateman at oracle.com
Tue Apr 10 08:18:03 PDT 2012


On 10/04/2012 16:12, Zhong Yu wrote:
> Thanks Alan. You are right, in the context of heavy I/O operations, my
> concern about threading overhead of the lightweight tasks is
> overblown.
>
> I'll simply use the default thread pool with unbounded number of
> threads. However one problem is that these threads never expire
>
>      class sun.nio.ch.ThreadPool
>          static ThreadPool createDefault() {
>
>              ExecutorService executor =
>                  new ThreadPoolExecutor(0, Integer.MAX_VALUE,
>                                     Long.MAX_VALUE, TimeUnit.MILLISECONDS,
>                                     new SynchronousQueue<Runnable>(),
>                                     threadFactory);
>
> After peak load, the extra threads will stay forever. Some users might
> find that unsettling. Shouldn't we set a human-scale timeout, like 60
> seconds?
>
It probably should, except for older versions of Windows where I/O 
operations are tied to the initiating thread so we can't let them 
terminate if there are outstanding I/O operations.

-Alan.


More information about the nio-dev mailing list