Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ISSUE] Feedback inapprotiate examples #16743

Open
XinAnzzZ opened this issue May 28, 2024 · 0 comments
Open

[ISSUE] Feedback inapprotiate examples #16743

XinAnzzZ opened this issue May 28, 2024 · 0 comments
Labels
on-jira triaged Issues reviewed by a dev and considered valid. Will be added in Jira.

Comments

@XinAnzzZ
Copy link

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.

@apeterlic apeterlic added the triaged Issues reviewed by a dev and considered valid. Will be added in Jira. label Jun 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
on-jira triaged Issues reviewed by a dev and considered valid. Will be added in Jira.
Projects
None yet
Development

No branches or pull requests

3 participants