<div dir="ltr"><div>Hello,</div><div><br></div><div>Log4j heavily relies on thread-locals (TLs) for object pooling. This becomes of particular importance for caching and garbage-free logging purposes. With JEP 425 (Virtual Threads), this becomes problematic due to two main issues:</div><div><br></div><div>1. TLs on vthreads yield no allocation benefits since vhtreads are short-lived. On the contrary, it becomes a redundant memory cost due to the excessive vthread count. In this case, Log4j still works, though slower and with increased memory footprint.</div><div><br></div><div>2. TL mutation can be disabled for vthreads. In this case, Log4j doesn't work, since TL setters throw UnsupportedOperationException.</div><div><br></div><div>Users experimenting with Java 19 have already started reporting these issues[1]. JEP 429 (Scoped values) might be the answer to our questions, yet I have the impression that there will be a time gap between the GA releases of vthreads and SVs. Hence I would like to know what is the best angle to address this problem using the tooling that will be provided by JEP 425.<br></div><div><br></div><div>I believe our use cases apply to many other major libraries in the wild. I would appreciate it if OpenJDK developers can help us with determining a way forward.</div><br><div>Kind regards.</div><div><br></div><div>[1] <a href="https://issues.apache.org/jira/browse/LOG4J2-3622">https://issues.apache.org/jira/browse/LOG4J2-3622</a></div></div>