ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/jsr166/jsr166/src/test/tck/ThreadLocalRandomTest.java
(Generate patch)

Comparing jsr166/src/test/tck/ThreadLocalRandomTest.java (file contents):
Revision 1.29 by jsr166, Sun Jan 28 16:41:13 2018 UTC vs.
Revision 1.30 by jsr166, Wed Aug 12 17:39:43 2020 UTC

# Line 357 | Line 357 | public class ThreadLocalRandomTest exten
357              new AtomicReference<>();
358          final AtomicLong rand = new AtomicLong();
359  
360        long firstRand = 0;
361        ThreadLocalRandom firstThreadLocalRandom = null;
362
360          Runnable getRandomState = new CheckedRunnable() {
361              public void realRun() {
362                  ThreadLocalRandom current = ThreadLocalRandom.current();
363                  assertSame(current, ThreadLocalRandom.current());
367                // test bug: the following is not guaranteed and not true in JDK8
368                //                assertNotSame(current, threadLocalRandom.get());
364                  rand.set(current.nextLong());
365                  threadLocalRandom.set(current);
366              }};
367  
368 <        Thread first = newStartedThread(getRandomState);
369 <        awaitTermination(first);
370 <        firstRand = rand.get();
371 <        firstThreadLocalRandom = threadLocalRandom.get();
368 >        awaitTermination(newStartedThread(getRandomState));
369 >        long firstRand = rand.get();
370 >        ThreadLocalRandom firstThreadLocalRandom = threadLocalRandom.get();
371 >        assertNotNull(firstThreadLocalRandom);
372  
373          for (int i = 0; i < NCALLS; i++) {
374 <            Thread t = newStartedThread(getRandomState);
375 <            awaitTermination(t);
374 >            awaitTermination(newStartedThread(getRandomState));
375 >            if (testImplementationDetails)
376 >                // ThreadLocalRandom has been a singleton since jdk8.
377 >                assertSame(firstThreadLocalRandom, threadLocalRandom.get());
378              if (firstRand != rand.get())
379                  return;
380          }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines