Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions thread-local-storage/src/test/java/ThreadLocalTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -57,15 +57,15 @@ public void withoutThreadLocal() throws InterruptedException {
int threadSize = 2;
ExecutorService executor = Executors.newFixedThreadPool(threadSize);

WithoutThreadLocal threadLocal = new WithoutThreadLocal(initialValue);
for (int i = 0; i < threadSize; i++) {
executor.submit(threadLocal);
//Create independent thread
WithoutThreadLocal threadLocal = new WithoutThreadLocal(initialValue);
executor.submit(threadLocal);
}
executor.awaitTermination(3, TimeUnit.SECONDS);

List<String> lines = outContent.toString().lines().toList();
//Matches only first thread, the second has changed by first thread value
Assertions.assertFalse(lines.stream()

Assertions.assertTrue(lines.stream()
.allMatch(line -> line.endsWith(String.valueOf(initialValue))));
}

Expand Down