Welcome! Please see the About page for a little more info on how this works.

+4 votes
in Printing by

The #inst printer uses java.text.SimpleDateFormat, which is not thread-safe. As per common Java practice (of yesteryear), the instance used is folded into a proxied ThreadLocal so all access per thread is thread-safe but no synchronization is needed. In Java 21, this is not ideal because virtual threads are numerous and there is little reuse within a single virtual thread, as there would have been before in a pooled non-virtual thread.

Instead, we should use the immutable formatter provided since Java 8 in java.time.format.DateTimeFormatter and not use a ThreadLocal for this.

1 Answer

0 votes
by
...