多并发下 SimpleDateFormat 出现错误
private static String time = "2019-01-11 11:11:11";
private static long timestamp = 1547176271000L;
private static SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); public static void main(String[] args) {
dateFormatTest(x->{
try {
Date date = dateFormat.parse(time);
if (date.getTime() != timestamp){
System.out.println("转化错误:"+date);
}
} catch (Exception e) {
System.out.println("出现异常"+e.getMessage());
}
});
}
private static void dateFormatTest(Consumer runnable){
CountDownLatch countDownLatch = new CountDownLatch();
for (int i = ; i < ; i++) {
new Thread(()->{
runnable.accept(null);
countDownLatch.countDown();
}).start();
}
try {
countDownLatch.await();
} catch (InterruptedException e) {
e.printStackTrace();
}
}
多并发下 SimpleDateFormat 出现错误的更多相关文章
- .net的页面在大并发下出现503错误
.net的页面在大并发下偶尔出现503错误 我们开发了一个回调页面,由一个工具负责调用,由于压力非常大,回调页面通过6台服务器负载均衡的: 最近业务系统又再次扩容,回调页面压力成倍增加,在高峰时间段偶 ...
- SimpleDateFormat 出现错误 Call requires API level 24 (current min is 15)
这个故事是这样的 今天写打卡时间的时候需要获取一下当前时间,然后我就写了一个这个 SimpleDateFormat sDF = new SimpleDateFormat("yyyy-MM ...
- SimpleDateFormat类的线程安全问题和解决方案
摘要:我们就一起看下在高并发下SimpleDateFormat类为何会出现安全问题,以及如何解决SimpleDateFormat类的安全问题. 本文分享自华为云社区<SimpleDateForm ...
- SimpleDateFormat类的安全问题,这6个方案总有一个适合你
摘要:你使用的SimpleDateFormat类还安全吗?为什么说SimpleDateFormat类不是线程安全的?带着问题从本文中寻求答案. 本文分享自华为云社区<[高并发]SimpleDat ...
- Docker 更新镜像
docker镜像如下: 今天在运行的容器内使用 apt-get update 命令进行更新时,发下很多404错误. Err http://archive.ubuntu.com wily-updates ...
- 深入浅出的webpack构建工具---PostCss(五)
一:PostCss是什么? PostCss是一个样式处理工具,它通过自定义的插件和工具生态体系来重新定义css.它鼓励开发者使用规范的css原生语法编写代码,然后配置编译器转换需要兼容的浏览器版本, ...
- 航空概论(历年资料,引之百度文库,PS:未调格式,有点乱)
航空航天尔雅 选择题1. 已经实现了<天方夜谭>中的飞毯设想.—— A——美国2. 地球到月球大约—— C 38 万公里3. 建立了航空史上第一条定期空中路线—— B——德国4. 对于孔明 ...
- .net的页面在大并发下偶尔出现503错误
我们开发了一个回调页面,由一个工具负责调用,由于压力非常大,回调页面通过6台服务器负载均衡的: 最近业务系统又再次扩容,回调页面压力成倍增加,在高峰时间段偶尔出现了503错误. 拿到这个问题首先对系统 ...
- SimpleDateFormat做成员或者静态成员多线程安全隐患
转自:http://blog.csdn.net/jeamking/article/details/7183958 有时我们在同一个类中都是使用同一种日期格式,又或者为了减少new SimpleDate ...
随机推荐
- HDU - 3499 Flight 双向SPFA+枚举中间边
Flight Recently, Shua Shua had a big quarrel with his GF. He is so upset that he decides to take a t ...
- SqlServer2012——多表连接查询
1.基本连接 select A.姓名,A.性别,B.班级名,B.家庭住址 From 学生信息 A,班级信息 B where A.所属班级=B.班级编号 --把A表与B表连接起来 2.内连接 --内连接 ...
- CentOS 安装配置vncserver
yum 安装tiger vncserver yum install tigervnc-server 安装后输入 vncserver 设置密码 3.配置用户 vim /etc/sysconfig/vnc ...
- maven分层架构搭建
1.准备工作: 1.创建数据源 CREATE TABLE `users` ( `id` int(10) NOT NULL AUTO_INCREMENT, `name` varchar(20) DEFA ...
- How to install your SSL Certificate to your Windows Server
Installation: Open the ZIP file containing your certificate. Save the file named your_domain_name.ce ...
- redis单机上部署集群
一.安装单机redis redis的安装:版本至少是3.2.8及其以上,这里以3.2.8版本为例说明 1.安装redis wget http://download.redis.io/releases ...
- Python-10-条件和条件语句
num = int(input('Enter a number: ')) if num > 0: print('The number is positive') elif num < ...
- Django之用户认证—auth模块
用户认知———auth模块 目录: auth模块 User对象 实例 扩展默认的auth_user表 - 创建超级用户 - python3 manager.py createsuperuser - 认 ...
- atom通过remote ftp同步本地文件到远程主机的方法
视频教程:https://ninghao.net/video/3991 搜索 “remote ftp”, 点击 “Package”搜索包,Install”安装 本地打开需要同步的项目目录 创建 rem ...
- Netty(2)Echo
上节介绍的是discard协议,即不给客户端返回消息.本节主要说下,echo协议,即服务端收到消息后原样返回给客户端. 为了实现此需求,只需要在DiscardServerHandler中重写chann ...