GithubHelp home page GithubHelp logo

请教一个问题 about redant HOT 2 CLOSED

all4you avatar all4you commented on July 22, 2024
请教一个问题

from redant.

Comments (2)

all4you avatar all4you commented on July 22, 2024

可以了解下 Netty 的 EventLoop 的执行过程,以及 Netty 的串行化设计。
另外 ThreadLocal 本身就是一种解决线程安全的方案,跟 Netty 没有关系。
同一个线程中处理多个不同的请求,如果每个请求的 Handler 都能保证是线程安全的,那就是安全的,和是否使用 ThreadLocal 没有太大的关系。

from redant.

pedrogao avatar pedrogao commented on July 22, 2024

打扰到了,我还是得追问一下。
Netty既然可以在单个线程里面处理多个不同的Handler,每个Handler都有其自己的session信息,这些放在ThreadLocal里面,公用一个线程的多个Handler的session信息可能就会造成污染。
例如:Handler1在ThreadLocal里面存放了session1,而同一线程的Handler2就有可能在同一时间通过ThreadLocal取到session1,那么就造成污染。
请问,您上面提到的Handler线程安全是如何保证ThreadLocal在这里安全的?谢谢了

from redant.

Related Issues (4)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.