What is the use of `ThreadLocal` in Java?

  1. To store thread pools
  2. To isolate variable values per thread
  3. To store the ID of a thread
  4. To create child threads
Correct answer To isolate variable values per thread

Explanation

`ThreadLocal` provides each thread its own isolated variable instance.

Update: Admin added a tag on this question

Topics

By Admin · · 29 views