Multithread issue in JBoss 7

2019-07-04 17:23发布

问题:

I have got a problem (or doubt) about multithreading in jboss 7. My situation is more or less simillar to situation described here:I have got piece of code that is running in many threads and now I have to move it to jboss server. Only thing that is different is that I don't use EJB, just spring+hibernate. So my question is: should I follow the same steps as was written in the answer or there is any other way that I can create many threads? (I was exploring jboss and there was some place to configure thread factory and thread pools and I don't know if it is tool that I can use in my app)

回答1:

no, not really. its "illegal" to create threads in Java EE and under the servlet specifcation. the link you pointed to it the easiest way to do threading under a web/Java EE container - use @Asynchronous. note that you can return a Future from such a method if you want to wait for the results