<div dir="ltr"><div dir="ltr"><div>Hi</div><div><br><table cellpadding="0" style="border-collapse:collapse;margin-top:0px;width:auto;font-family:"Google Sans",Roboto,RobotoDraft,Helvetica,Arial,sans-serif;font-size:14px;display:block"><tbody style="display:block"><tr style="height:auto;display:flex"><td style="white-space:nowrap;padding:0px;vertical-align:top;width:869.19px;line-height:20px;display:block;max-height:20px"></td></tr></tbody></table></div><div>I've been testing one of my applications in JDK20 preview mode on Windows - conversion to use virtual threads has been very easy and works well - many thanks to everyone involved. One bug I found turned out to be in my own codebase.</div><div><br></div><div>I happened to be stripping out all my ThreadLocal code recently, and so decided to check this work by adding "allowSetThreadLocals(false)" onto all virtual thread builders to disable ThreadLocal use.  </div><div><br></div><div>This is when I discover that javax.imageio.ImageIO initialisation depends on ThreadLocal. The stack trace points at IIORegistry initialisation:</div><div><br></div><div>       at java.desktop/javax.imageio.spi.IIORegistry.getDefaultInstance(Unknown Source)<br>       at java.desktop/javax.imageio.ImageIO.<clinit>(Unknown Source)<br></div><div><br></div><div>Obviously I've got an easy workaround - "allowSetThreadLocals(true)" puts it back to working reliably, plus it appears that using some call like "ImageIO.getCache()" in main() also reduces likelyhood of this exception as it initialises enough of ImageIO before use in multiple threads.</div><div><br></div><div>Are there any plans to unpick the ThreadLocal dependency inside javax.imageio.ImageIO for future JDK work? <br></div><div><br></div><div>Kind regards<br></div><div><br></div><div>Duncan Gittins</div><div><br></div></div></div>