当前位置:网站首页>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 .
边栏推荐
- [C language] string function and Simulation Implementation strlen & strcpy & strcat & StrCmp
- 浮动元素与父级、兄弟盒子的关系
- XaaS 陷阱:万物皆服务(可能)并不是IT真正需要的东西
- Microwave radar induction module technology, real-time intelligent detection of human existence, static micro motion and static perception
- IBM大面积辞退40岁+的员工,掌握这十个搜索技巧让你的工作效率至上提高十倍
- 全网最全的低代码/无代码平台盘点:简道云、伙伴云、明道云、轻流、速融云、集简云、Treelab、钉钉·宜搭、腾讯云·微搭、智能云·爱速搭、百数云
- Fundamentals of shell programming (Chapter 9: loop)
- Is it safe for Guohai Securities to open an account online?
- Reinforcement learning - learning notes 4 | actor critical
- 力扣 729. 我的日程安排表 I
猜你喜欢

Debezium series: record the messages parsed by debezium and the solutions after the MariaDB database deletes multiple temporary tables

How about testing outsourcing companies?
PHP uses ueditor to upload pictures and add watermarks
![[C language] string function and Simulation Implementation strlen & strcpy & strcat & StrCmp](/img/32/738df44b6005fd84b4a9037464e61e.jpg)
[C language] string function and Simulation Implementation strlen & strcpy & strcat & StrCmp

How to convert word into PDF? Word to PDF simple way to share!

集合

Worthy of being a boss, byte Daniel spent eight months on another masterpiece

浅浅的谈一下ThreadLocalInsecureRandom
Successful entry into Baidu, 35K monthly salary, 2022 Android development interview answer

No matter how busy you are, you can't forget safety
随机推荐
MMO project learning 1: preheating
Gstreamer中的task
Inventory of the most complete low code / no code platforms in the whole network: Jiandao cloud, partner cloud, Mingdao cloud, Qingliu, xurong cloud, Jijian cloud, treelab, nailing · Yida, Tencent clo
[Collection - industry solutions] how to build a high-performance data acceleration and data editing platform
How to choose the notion productivity tools? Comparison and evaluation of notion, flowus and WOLAI
What is the core value of testing?
The relationship between temperature measurement and imaging accuracy of ifd-x micro infrared imager (module)
Add data to excel small and medium-sized cases through poi
95后阿里P7晒出工资单:狠补了这个,真香...
力扣 1200. 最小绝对差
The city chain technology Digital Innovation Strategy Summit was successfully held
Fundamentals of shell programming (Chapter 9: loop)
Is the education of caiqiantang reliable and safe?
Xaas trap: all things serve (possible) is not what it really needs
Multi branch structure
Where is the operation of new bonds? Is it safer and more reliable to open an account
C#应用程序界面开发基础——窗体控制(6)——菜单栏、工具栏和状态栏控件
okcc呼叫中心有什么作用
No matter how busy you are, you can't forget safety
完爆面试官,一线互联网企业高级Android工程师面试题大全