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

技术细节之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 Calenderstatic SimpleDateFormat 吧,隐患啊,而且一般测试测不出来的。

REFER:  http://sharajava.iteye.com/blog/81551

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 Calenderstatic SimpleDateFormat 吧,隐患啊,而且一般测试测不出来的。

REFER:  http://sharajava.iteye.com/blog/81551

猜你喜欢

转载自eyesmore.iteye.com/blog/1296611