By screener
via javarevisited.blogspot.com
Published: Jun 11 2012 / 22:46
SimpleDateFormat is not a thread-safe class and we can not share it between multiple thread but same time using local SimpleDateFormat is expensive and a better alternative of this is using ThreadLocal variable which allows each Thread to hold its SimpleDateFormat class and since it is not shared between multiple thread, it become thread safe. Overall simple example of ThreadLocal variable in Java to understand it better.
Comments
javawerks replied ago:
Just use immutable joda time objects, and ignore this nonsense.
devdanke replied ago:
While I prefer the Joda date-time library, I think the solution proposed in this article is clever and simple.
Voters For This Link (8)
Voters Against This Link (1)