Doubts about the use of threadlocal as session Management

multiple requests from a user are most likely not in the same thread. Suppose the first request is thread A, which is stored in threadLoacl. The second request is thread B. isn"t it impossible to get the session of the first request from the current thread? Or maybe user 1 requests the service first and puts the session in the threadlocal of thread a, and user 2 also uses this thread, and user 2 stores the session in the threadlocal of thread a, doesn"t it overwrite the session pollution of user 1?

Aug.18,2021

just

  1. each request is completed in one thread
  2. set the threadLocal correctly at the beginning of every other request and clear the threadLocal correctly at the end of the threadLocal,

is fine


this article is easy to understand. Recommend it:
https://www.ixigua.com/6872736339528417792/

Menu