当前位置:网站首页>Let's talk about threadlocalinsecurerandom
Let's talk about threadlocalinsecurerandom
2022-07-05 19:50:00 【Bulst】
I took a look at random number correlation today , Accidentally found this class .
This looks really good , There is an inheritance SecurityRandom, And with ThreadLocal word , Does it have the characteristics of both , Become a combination ?
Let's explore how .
First, let's see how it generates random numbers
@Override
public int nextInt() {
return random().nextInt();
}
track , Looks like this random Method is its core .
private static Random random() {
return PlatformDependent.threadLocalRandom();
}
PlatformDependent yes netty Under the , We'll talk about it later .
track
public static Random threadLocalRandom() {
return RANDOM_PROVIDER.current();
}
track
private interface ThreadLocalRandomProvider {
Random current();
}
track , Oh ~
It's here , It used to be on the bottom floor ThreadLocalRandom ah , Not out of date jdk7 And above , use jdk In this way .
static {
if (javaVersion() >= 7) {
RANDOM_PROVIDER = new ThreadLocalRandomProvider() {
@Override
@SuppressJava6Requirement(reason = "Usage guarded by java version check")
public Random current() {
return java.util.concurrent.ThreadLocalRandom.current();
}
};
} else {
RANDOM_PROVIDER = new ThreadLocalRandomProvider() {
@Override
public Random current() {
return ThreadLocalRandom.current();
}
};
}
Take a look at netty and jdk Under the ThreadLocalRandom Realization way , There is still a big difference , If you are interested, go and have a look by yourself .
I have a look back ThreadLocalInsecureRandom Is not public Embellished , Nothing , Class is over .
边栏推荐
- Successful entry into Baidu, 35K monthly salary, 2022 Android development interview answer
- IBM大面积辞退40岁+的员工,掌握这十个搜索技巧让你的工作效率至上提高十倍
- UWB超宽带定位技术,实时厘米级高精度定位应用,超宽带传输技术
- MySQL中字段类型为longtext的值导出后显示二进制串方式
- Reinforcement learning - learning notes 4 | actor critical
- 【FAQ】华为帐号服务报错 907135701的常见原因总结和解决方法
- Bitcoinwin (BCW)受邀参加Hanoi Traders Fair 2022
- redis集群模拟消息队列
- Hiengine: comparable to the local cloud native memory database engine
- What are general items
猜你喜欢
Do you know several assertion methods commonly used by JMeter?
深度學習 卷積神經網絡(CNN)基礎
浅浅的谈一下ThreadLocalInsecureRandom
如何安全快速地从 Centos迁移到openEuler
【合集- 行业解决方案】如何搭建高性能的数据加速与数据编排平台
C#应用程序界面开发基础——窗体控制(5)——分组类控件
Recommended collection, my Tencent Android interview experience sharing
MMO项目学习一:预热
PHP利用ueditor实现上传图片添加水印
40000 word Wenshuo operator new & operator delete
随机推荐
Reflection and imagination on the notation like tool
软件测试工程师是做什么的?待遇前景怎么样?
什么是面上项目
安卓面试宝典,2022Android面试笔试总结
C#应用程序界面开发基础——窗体控制(6)——菜单栏、工具栏和状态栏控件
四万字长文说operator new & operator delete
常用运算符与运算符优先级
Information / data
Common operators and operator priority
不愧是大佬,字节大牛耗时八个月又一力作
How to safely and quickly migrate from CentOS to openeuler
How about testing outsourcing companies?
How to apply smart contracts more wisely in 2022?
okcc呼叫中心有什么作用
深度學習 卷積神經網絡(CNN)基礎
IBM has laid off 40 + year-old employees in a large area. Mastering these ten search skills will improve your work efficiency ten times
Debezium series: parsing the default value character set
力扣 1200. 最小绝对差
Reinforcement learning - learning notes 4 | actor critical
【合集- 行业解决方案】如何搭建高性能的数据加速与数据编排平台