Fast graceful shutdown of ThreadPerTaskExecutor (when expected WAITING Threads)
Alan Bateman
Alan.Bateman at oracle.com
Tue Dec 27 10:59:07 UTC 2022
On 21/12/2022 14:58, Arnaud Masson wrote:
>
> > The way to interrupt sockets has always been to close them. Then blocking methods will throw an exception.
>
> I didn’t test but I was hoping that “JEP 353: Reimplement the Legacy
> Socket API” made classic socket API interruptible (like NIO) .
>
> This would make socket API so much more consistent with other blocking
> stuff.
>
>
JEP 353 put in the foundation to enable this and JEP 425 makes use of
it, see the Networking section [1] in the JEP and specifically:
"To allow for interruption and cancellation, the blocking I/O methods
defined by java.net.Socket, ServerSocket, and DatagramSocket are now
specified to be interruptible when invoked in a virtual thread"
So in the HTTP/1.1 scenario here, where a virtual thread is blocked on
an idle persistent connection, the shutdownNow will cause the virtual
thread to wakeup and close the connection.
-Alan
[1] https://openjdk.org/jeps/425#Networking
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.org/pipermail/loom-dev/attachments/20221227/28bffd22/attachment.htm>
More information about the loom-dev
mailing list