Using BufferedReader and InputStreamReader with virtual threads
karsten at soit.de
karsten at soit.de
Mon Aug 10 14:37:38 UTC 2020
Hi @all,
i started experimenting with loom and virtual threads [thanks for this
nice project].
I know, that suspending virtual threads leads to thread-pinning if
synchronized frames are on the stack.
My question is: when using classes like BufferedReader or
InputStreamReader on blocking streams (e.g. TCP-Inputstreams) the
os-workerthread will be blocked (virtual-thread is unable to yield),
since the abstract Reader-Class and classes like
sun.nio.cs.StreamDecoder use internal synchronization (read()-method of
tcp-stream is called from synchronized-block).
I think, this may prevent many existing libs (e.g. jdbc-drivers) to
benefit from virtual threads. Is there a plan to optimize these classes
to be more 'virtual-thread-friendly'?
greetz and thanks for your effort,
Karsten
More information about the loom-dev
mailing list