1
JavaIntermediate#concurrency
ThreadLocal provides a variable with a separate copy for each thread accessing it, useful for per-thread context like database connections, user sessions, or date formatters without synchronization overhead.
ThreadLocal<SimpleDateFormat> formatter = ThreadLocal.withInitial(() -> new SimpleDateFormat("yyyy-MM-dd"));
formatter.get().format(new Date());