Skip to content
Permalink
Browse files
Use Java 1.8 method to compute map value if absent
  • Loading branch information
aherbert committed Mar 17, 2022
1 parent 27abd76 commit 60213ea3856fb6b35705dbd2cf50d14c7bdf8bb8
Showing 1 changed file with 1 addition and 5 deletions.
@@ -122,11 +122,7 @@ public static UniformRandomProvider current(RandomSource source) {
}

synchronized (SOURCES) {
rng = SOURCES.get(source);
if (rng == null) {
rng = new ThreadLocalRng(source);
SOURCES.put(source, rng);
}
rng = SOURCES.computeIfAbsent(source, s -> new ThreadLocalRng(s));
}
}
return rng.get();

0 comments on commit 60213ea

Please sign in to comment.