6 ms·
Not being well versed in the capabilities of the virtual threads. However, both the Servlet and the JAX-RS models are "thread agnostic" in that while we "know"
by whartung 3y ago
Not being well versed in the capabilities of the virtual threads. However, both the Servlet and the JAX-RS models are "thread agnostic" in that while we "know" we're running on a thread, the API doesn't expose it directly.
So, if something like Tomcat "simply" switch its internal threading model from the current model to the virtual model, would the applications know any different? Could you drag and drop a JAX-RS service or a Java Servlet into a container running on virtual threads, or would rapidly run into some leaky wall?
Seems like a virtual thread model of Tomcat would be quite useful in some scenarios.
- doctorpangloss 3y agoIn order to use those things, you have to write annotations. With Nima, you just write the code to do the thing. It's a huge difference. If you have the wisdom to see how toxic annotation-driven programming in Java is, you will like Nima. Helidon Nima is more comparable to building services in golang. It's more like Vert.x but with a serial API.
- Tainnor 3y agoThere are ways of writing Spring without annotations (or XML config): https://blog.frankel.ch/annotation-free-spring/ https://blog.frankel.ch/annotation-free-spring/ Granted, they may not be used much, but if you have an existing application it's probably easier to migrate away from the annotations than to switch to a different framework altogether.
- mongol 3y agoServlets existed before annotations, so no, you are wrong.
- antonhag 3y agoCounter-example: https://javalin.io/ https://javalin.io/ uses Servlets, and seems to be doing quite fine without annotations.
- kimi 3y agoIt definitely would. I - for one - won't be rewriting our 20+ year old servlet app in anything else but servlets, because it has proven to be an exceptionally stable environment. More than virtual threads for Tomcat requests, I'd love cheap, structured threads to be run from within a request, eg to access the database while I'm reading a webservice.
- mikko-apo 3y agoJDK21 has structured concurrency. It works with virtual threads so the main task will be moved aside (from the OS thread) until the sub tasks finnish. https://www.infoq.com/news/2023/06/structured-concurrency-jdk-21/ https://www.infoq.com/news/2023/06/structured-concurrency-jd...
- kimi 3y agoYes, that's what I was referring to.