Making DateFormat Threadsafe. What to use, synchronized or Thread local

前端 未结 6 1526
甜味超标
甜味超标 2020-12-17 22:14

I want to make following code thread safe. What is the best way to achieve it?

private static final DateFormat DATE_FORMAT = DateFormat.getDateTimeInstance(         


        
6条回答
  •  醉梦人生
    2020-12-17 22:38

    Better, use: org.apache.commons.lang.time.FastDateFormat (is a fast and thread-safe version of SimpleDateFormat)

提交回复
热议问题