mirror of
https://github.com/AsamK/signal-cli
synced 2025-08-29 18:40:39 +00:00
Use lambda for ThreadLocal
This commit is contained in:
parent
e2b7bda65b
commit
0ce64dc923
1 changed files with 6 additions and 9 deletions
|
@ -5,17 +5,14 @@ import java.security.SecureRandom;
|
||||||
|
|
||||||
public class RandomUtils {
|
public class RandomUtils {
|
||||||
|
|
||||||
private static final ThreadLocal<SecureRandom> LOCAL_RANDOM = new ThreadLocal<SecureRandom>() {
|
private static final ThreadLocal<SecureRandom> LOCAL_RANDOM = ThreadLocal.withInitial(() -> {
|
||||||
@Override
|
SecureRandom rand = getSecureRandomUnseeded();
|
||||||
protected SecureRandom initialValue() {
|
|
||||||
SecureRandom rand = getSecureRandomUnseeded();
|
|
||||||
|
|
||||||
// Let the SecureRandom seed it self initially
|
// Let the SecureRandom seed it self initially
|
||||||
rand.nextBoolean();
|
rand.nextBoolean();
|
||||||
|
|
||||||
return rand;
|
return rand;
|
||||||
}
|
});
|
||||||
};
|
|
||||||
|
|
||||||
private static SecureRandom getSecureRandomUnseeded() {
|
private static SecureRandom getSecureRandomUnseeded() {
|
||||||
try {
|
try {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue