InterviewSolution
Saved Bookmarks
| 1. |
What do you mean by the ThreadLocal variable in Java? |
|
Answer» ThreadLocal variables are special KINDS of variables created and provided by the Java ThreadLocal class. These variables are only allowed to be read and written by the same thread. Two threads cannot be able to see each other’s ThreadLocal variable, so even if they will execute the same code, then there won't be any race condition and the code will be thread-safe. Output: 10 33 10 33 |
|