Why pool Stateless session beans?

后端 未结 5 613
半阙折子戏
半阙折子戏 2020-12-02 19:04

Stateless beans in Java do not keep their state between two calls from the client. So in a nutshell we might consider them as objects with business methods. Each method take

5条回答
  •  一整个雨季
    2020-12-02 19:38

    Methods by nature ARE THREAD SAFE (including static). Why? Simple, because every variable inside the method is created in the stack memory, i.e. every variable used inside the method is created per call (it's not shared). However, parameters aren't part of the stack.

    However, a method is unsafe if it uses an unsafe variable:

    a) calling a static field or variable. However, it happens in every single case.

    b) calling a resource that it's shared. Such as the EntityManager.

    c) passing a parameter that is not safe.

提交回复
热议问题