eugenp/tutorials

[ISSUE] Feedback inapprotiate examples

XinAnzzZ opened this issue · 0 comments

Article and Module Links
https://www.baeldung.com/java-threadlocal

core-java-modules/core-java-concurrency-advanced/src/test/java/com/baeldung/threadlocal/ThreadLocalIntegrationTest.java

Describe the Issue
In the 4th chapter of this article, I believe there is a mistake in your demonstration of how to use ThreadLocal, the example does not effectively illustrate the true functionality of ThreadLocal.

The main functionality of ThreadLocal is for thread isolate, actully, you have created two objects, thus they have own threadlocal
object, i believe that there are no share

The purpose of ThreadLocal is to provide thread isolation. However, the code example you provided actually creates two separate ThreadLocal objects, with each thread having its own independent ThreadLocal object. I believe that this does not demonstrate thread sharing and, as a result, fails to illustrate the effect of thread isolation.