当前位置:网站首页>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 .
边栏推荐
- JMeter 常用的几种断言方法,你会了吗?
- PHP利用ueditor实现上传图片添加水印
- 再忙不能忘安全
- Using repositoryprovider to simplify the value passing of parent-child components
- Bitcoinwin (BCW) was invited to attend Hanoi traders fair 2022
- 浅浅的谈一下ThreadLocalInsecureRandom
- Vagrant2.2.6 supports virtualbox6.1
- 国海证券在网上开户安全吗?
- MMO project learning 1: preheating
- 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
猜你喜欢
Django uses mysqlclient service to connect and write to the database

Hiengine: comparable to the local cloud native memory database engine
![[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

Webuploader file upload drag upload progress monitoring type control upload result monitoring control

S7-200SMART利用V90 MODBUS通信控制库控制V90伺服的具体方法和步骤

不愧是大佬,字节大牛耗时八个月又一力作
How MySQL queries and modifies JSON data

Zhongang Mining: analysis of the current market supply situation of the global fluorite industry in 2022
![[AI framework basic technology] automatic derivation mechanism (autograd)](/img/9c/a5713def131dc7643cc19b3839ff0c.png)
[AI framework basic technology] automatic derivation mechanism (autograd)

Force buckle 729 My schedule I
随机推荐
C application interface development foundation - form control (6) - menu bar, toolbar and status bar controls
【C语言】字符串函数及模拟实现strlen&&strcpy&&strcat&&strcmp
Tasks in GStreamer
Postman core function analysis - parameterization and test report
【obs】libobs-winrt :CreateDispatcherQueueController
PG basics -- Logical Structure Management (user and permission management)
40000 word Wenshuo operator new & operator delete
c——顺序结构
The binary string mode is displayed after the value with the field type of longtext in MySQL is exported
Webuploader file upload drag upload progress monitoring type control upload result monitoring control
挖财钱堂教育靠谱安全吗?
Fundamentals of shell programming (Part 8: branch statements -case in)
建立自己的网站(16)
[hard core dry goods] which company is better in data analysis? Choose pandas or SQL
ACM getting started Day1
多分支结构
浅浅的谈一下ThreadLocalInsecureRandom
【obs】QString的UTF-8中文转换到blog打印 UTF-8 char*
[Collection - industry solutions] how to build a high-performance data acceleration and data editing platform
PHP uses ueditor to upload pictures and add watermarks