I am new to multithreading in Java and EJB too. I have a scenario where I have to hit a web service concurrently using threads. I have got two approaches for that.
- Using ExecutorService with Callable to hit the service concurrently.
- Using @Asynchronous annotation of EJB.
What I have read is: EJB recommends to use @Asynchronous over writing our own threaded implementation. After reading this I am confused about why EJB says so. Because underneath EJB works on JVM and all threads will be created from JVM. So why EJB restricts us on using it's @Asynchronous rather than our implementation.
I searched on google but did not found any satisfactory answer. If anyone knows the details of thread creation and management in EJB please clear my doubts.