EJB's and Threading

前端 未结 4 904
醉话见心
醉话见心 2021-02-06 08:55

From what I understand it is illegal to spawn threads from within an EJB as it may potentially interfere with the EJB\'s lifecycle. However, is it illegal to use predefined Java

4条回答
  •  有刺的猬
    2021-02-06 09:31

    You "cannot" (should not) use threads, thread pools, executors... all of the above. the point of using an app server is to only write business logic and let the app server do the heavy lifting. if you really, really need to do your own threading, use an EJB 3.1 "singleton" service to manage the threading. however, as mentioned by others, it's best to leave this to the app server. one way to do parallel processing in an app server is to use MDBs (which it sounds like you already are using), although depending on the type of parallel processing, these may be too heavyweight.

提交回复
热议问题