AutoCloseable blocking or not
Kasper Nielsen
kasperni at gmail.com
Fri Oct 5 02:42:35 PDT 2012
Hi,
I have a question about the AutoCloseable interface. Since I cannot
find any mention about how asynchronously closeable resources should
be handled.
Say I wanted juc.ThreadPoolExecutorService to implement AutoCloseable.
When close() returned should the executor be in the shutdown phase or
in the terminated phase?
In other words should I implement close() like this (which I believe)
public void close() {
executor.shutdown();
executor.awaitTermination(Long.MAX_VALUE, TimeUnit.SECONDS); //ignore
any interrupted exceptions
}
or like this
public void close() {
executor.shutdown();
}
- Kasper
More information about the nio-discuss
mailing list