rschmitt commented on PR #717:
URL:
https://github.com/apache/httpcomponents-client/pull/717#issuecomment-3393530661
> Virtual threads let blocking HttpClient scale: thousands of concurrent
requests without bloated platform threads.
In your example code, when you call:
```
httpclient.execute(httpget, response -> { ... });
```
You are blocking a platform thread, which waits for the request to execute
on a virtual thread. I don't see how you can realize increased concurrency in
this way; it's still a thread-per-request model, and you might as well just
call into the client directly from the OS thread.
The whole advantage of virtual threads over async/await is that virtual
threads don't introduce function coloring. They are largely transparent to
libraries. They allow everyone to write blocking, imperative code and scale up
the concurrency by simply using a virtual thread factory instead of a
conventional thread factory. And since HttpComponents is a pure Java library,
we don't have to worry about pinning the carrier thread through blocking JNI
calls or anything; Java already fixed that problem for us with [JEP
353](https://openjdk.org/jeps/353), and more recently [JEP
491](https://openjdk.org/jeps/491) made `synchronized` work correctly with
virtual threads. I'm not sure there's a single thing we need to do to "enable"
virtual threads; am I missing something here?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]