Telephone interview asked Threadlocal what to pay attention to use. Find relevant information on the Internet
Threadlocal can save local variables for the current thread, while inheritablethreadlocal can pass local variables of the parent thread to child threads when creating child threads.
If a thread pool (such as executor) is used, the child thread still exists and is pooled even though the parent thread has ended. Thus, the Threadlocal object's Get () method returns a variable that is not set in the current thread when the thread in the thread pool executes the next request, because the "child thread" in the pool is not created by the current thread. The threadlocal variable set by the current thread cannot be passed to the thread in the thread pool.
Therefore, you must explicitly pass the threadlocal variable in the external thread to the thread in the thread pool.
Interview refers to related issues:
The difference between a session and a cookie that describes a complete process for a page request.
High concurrency is how to deal with.
Database-related optimizations how to do it.