File tree Expand file tree Collapse file tree 2 files changed +8
-8
lines changed
performance/src/main/java/org/hibernate/validator/performance Expand file tree Collapse file tree 2 files changed +8
-8
lines changed Original file line number Diff line number Diff line change 66 */
77package org .hibernate .validator .performance .simple ;
88
9- import java .util .Random ;
109import java .util .Set ;
10+ import java .util .concurrent .ThreadLocalRandom ;
1111import java .util .concurrent .TimeUnit ;
1212
1313import javax .validation .ConstraintViolation ;
@@ -51,13 +51,13 @@ public class SimpleValidation {
5151 @ State (Scope .Benchmark )
5252 public static class ValidationState {
5353 public volatile Validator validator ;
54- public volatile Random random ;
54+ public volatile ThreadLocalRandom random ;
5555 public volatile Driver [] drivers ;
5656
5757 {
5858 ValidatorFactory factory = Validation .buildDefaultValidatorFactory ();
5959 validator = factory .getValidator ();
60- random = new Random ();
60+ random = ThreadLocalRandom . current ();
6161
6262 drivers = new Driver [100 ];
6363 for ( int i = 0 ; i < 100 ; i ++ ) {
@@ -123,7 +123,7 @@ private static class DriverSetup {
123123 private int expectedViolationCount ;
124124 private Driver driver ;
125125
126- public DriverSetup (Random random ) {
126+ public DriverSetup (ThreadLocalRandom random ) {
127127 expectedViolationCount = 0 ;
128128
129129 String name = names [random .nextInt ( 10 )];
Original file line number Diff line number Diff line change 66 */
77package org .hibernate .validator .performance .unconstrained ;
88
9- import java .util .Random ;
109import java .util .Set ;
10+ import java .util .concurrent .ThreadLocalRandom ;
1111import java .util .concurrent .TimeUnit ;
1212
1313import javax .validation .ConstraintViolation ;
@@ -48,13 +48,13 @@ public class UnconstrainedBeanValidation {
4848 @ State (Scope .Benchmark )
4949 public static class ValidationState {
5050 public volatile Validator validator ;
51- public volatile Random random ;
51+ public volatile ThreadLocalRandom random ;
5252 private volatile Driver [] drivers ;
5353
5454 {
5555 ValidatorFactory factory = Validation .buildDefaultValidatorFactory ();
5656 validator = factory .getValidator ();
57- random = new Random ();
57+ random = ThreadLocalRandom . current ();
5858
5959 drivers = new Driver [100 ];
6060 for ( int i = 0 ; i < 100 ; i ++ ) {
@@ -109,7 +109,7 @@ private static class DriverSetup {
109109
110110 private Driver driver ;
111111
112- public DriverSetup (Random random ) {
112+ public DriverSetup (ThreadLocalRandom random ) {
113113 String name = names [random .nextInt ( 10 )];
114114
115115 int randomAge = random .nextInt ( 100 );
You can’t perform that action at this time.
0 commit comments