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吧,隐患啊,而且一般测试测不出来的。
分享到:
相关推荐
目录SimpleDateFormat诡异bug复现SimpleDateFormat诡异bug字符串日期转Date日期(parse)Date日期转String类型(format)SimpleDateFormat出现...事项使用ThreadLocal解决SimpleDateFormat线程安全问题总结...
高并发之-SimpleDateFormat类的线程安全问题和解决方案.docx
SimpleDateFormat线程不安全的5种解决方案.md
SimpleDateFormat线程不安全的5种解决方案.docx
主要介绍了SimpleDateFormat的线程安全问题与解决方案,非常不错,具有参考借鉴价值,需要的朋友可以参考下
NULL 博文链接:https://flynndang.iteye.com/blog/711878
关于SimpleDateFormat的非线程安全问题及其解决方案.docx
主要介绍了Java SimpleDateFormat线程安全问题原理详解,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友可以参考下
Java标准库中的一些类如ArrayList、HashMap和SimpleDateFormat,都是非线程安全的,在多线程环境下直接使用它们可能导致一些非预期的结果,甚至是一些灾难性的结果。一般来说,Java标准库中的类在其API文档中会说明...
深入理解Java:SimpleDateFormat安全的时间格式化
主要介绍了Java多线程环境下SimpleDateFormat类安全转换,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友们下面随着小编来一起学习学习吧
有关SimpleDateFormat的常用方法说明
JavaScript实现的java.text.SimpleDateFormat。希望多多交流。
日期操作。。。基础的SimpleDateFormat格式化日期!!操作!》初级学习代码
java代码-SimpleDateFormat YYYY解析问题
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); date.setTime(time); System.out.println(sdf.format(date)); 发现时间于想要的时间不符,请运行Time.reg文件
由浅入深解析 SimpleDateFormat 由浅入深解析 SimpleDateFormat
SimpleDateFormat使用详解。非常实用!!!!
java 使用SimpleDateFormat类获取系统的当前时间 java 使用SimpleDateFormat类获取系统的当前时间