当前位置:网站首页>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 .
边栏推荐
- MMO project learning 1: preheating
- Zhongang Mining: analysis of the current market supply situation of the global fluorite industry in 2022
- SecureRandom那些事|真伪随机数
- Is it safe for China Galaxy Securities to open an account? Securities account opening
- How about testing outsourcing companies?
- Vagrant2.2.6 supports virtualbox6.1
- Is it safe for Guohai Securities to open an account online?
- The relationship between temperature measurement and imaging accuracy of ifd-x micro infrared imager (module)
- acm入门day1
- 深度学习 卷积神经网络(CNN)基础
猜你喜欢
通过POI追加数据到excel中小案例
How to apply smart contracts more wisely in 2022?
Xaas trap: all things serve (possible) is not what it really needs
third-party dynamic library (libcudnn.so) that Paddle depends on is not configured correctl
Webuploader file upload drag upload progress monitoring type control upload result monitoring control
【obs】QString的UTF-8中文转换到blog打印 UTF-8 char*
Password reset of MariaDB root user and ordinary user
[AI framework basic technology] automatic derivation mechanism (autograd)
Force buckle 1200 Minimum absolute difference
IBM大面积辞退40岁+的员工,掌握这十个搜索技巧让你的工作效率至上提高十倍
随机推荐
函数的概念及语法
随机数生成的四种方法|Random|Math|ThreadLocalRandom|SecurityRandom
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
[hard core dry goods] which company is better in data analysis? Choose pandas or SQL
UWB ultra wideband positioning technology, real-time centimeter level high-precision positioning application, ultra wideband transmission technology
S7-200smart uses V90 Modbus communication control library to control the specific methods and steps of V90 servo
Float. The specific meaning of the return value of floattorawintbits is to convert float into byte array
力扣 1200. 最小绝对差
Worthy of being a boss, byte Daniel spent eight months on another masterpiece
Android interview, Android audio and video development
Gstreamer中的task
从零实现深度学习框架——LSTM从理论到实战【实战】
太牛了,看这篇足矣了
How to convert word into PDF? Word to PDF simple way to share!
软件测试是干什么的?学习有啥要求?
okcc呼叫中心有什么作用
40000 word Wenshuo operator new & operator delete
Multi branch structure
Postman core function analysis - parameterization and test report
Debezium series: record the messages parsed by debezium and the solutions after the MariaDB database deletes multiple temporary tables