当前位置:网站首页>Simpledateformat thread unsafe

Simpledateformat thread unsafe

2022-06-24 20:58:00 Little craftsman's heart

simpleDateFormat The bottom layer uses the calendar object creation time , The loading of object classes will cause thread insecurity due to instruction rearrangement during class loading . Encountered in the actual development process , Two different orders generate the same unique order number at the same time ~ It is operated by different people , No insurance policy . A system exception occurred in the middle , That is, the data interaction is suspended ~ terms of settlement , meet an emergency , Counter table id Set the primary key to grow automatically .( Self view , Use synchronized Adding details to the generated order number position is a breakthrough to solve concurrency , But it does not apply to high concurrency .2, Use thread safe time to create methods ,currentTimeMillus. These can only solve some low-level frameworks without threading policy . More advanced frameworks should have their own threading strategy , Or applicable redis Cooperate with snowflake algorithm to generate order number , Or use Uuid.) Of course, these are just the pits I encountered in my work , We also welcome the great gods who read this article to give us more advice

原网站

版权声明
本文为[Little craftsman's heart]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/02/202202211324146636.html