r/java • • Jun 01 '24

What java technology (library, framework, feature) would not recommend and why?

165 Upvotes

464 comments sorted by

View all comments

11

u/cowwoc Jun 01 '24

Async libraries that can be replaced by virtual threads. The code they produce is exponentially harder to read, write and debug.

If you can use virtual threads, you should absolutely drop these libraries and move into the future.

2

u/MaraKaleidoscope Jun 04 '24

We tried moving a workload to virtual threads but hit a snag where the application would deadlock because a library we depend on uses synchronized blocks and blocking operations. 

After that experience, our team decided no future code can use virtual threads until the pinning issues are addressed.  It is not feasible for us to review otherwise correct, thread-safe code down to the implementation details in order to determine whether any of our code…but mostly 3rd-party library code…has conditions which will generate deadlock. 

I am honestly surprised people are willing to take this risk in Production systems when it is so clear that virtual threads are not drop-in-replacements for platform threads (not implying that the JDK team claims otherwise, to be clear).

→ More replies (1)