`
sharajava
  • 浏览: 65690 次
  • 性别: Icon_minigender_1
  • 来自: 北京
社区版块
存档分类
最新评论

技术细节之SimpleDateFormat线程安全问题

    博客分类:
  • Java
阅读更多

Date formats are not synchronized. It is recommended to create separate format instances for each thread. If multiple threads access a format concurrently, it must be synchronized externally.

http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6231579

Sun refused to accept this issue as a BUG, so we have to handle the thread-safe by ourselves.

REF:http://jroller.com/page/dschneller?entry=calendar_dateformat_and_multi_threading


java.util.Calendar也存在这个问题,更差的是,其Javadoc中一字也未提到。

搜索代码中static Calender和static SimpleDateFormat吧,隐患啊,而且一般测试测不出来的。

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics