In case of Servlet - if 10 clients are accessing the servlet then there will be only 1 servlet instance and 10 threads get created in the container, which are accessed by 10 clients.
Now In case of EJB- consider 10 clients sending message to JMS Queue and OpenAccountMDB consumes the message and calls the OpenAccountBean session bean method.
Then in this scenario container pulls 10 OpenAccountMDB instances from the pool and creates 10 OpenAccountBean session bean instances.
Then is there any role of threading in EJB ? like Servlet has? What kind of multi threading is taken care by EJB container?
The container takes care of threading. In the case of MDB's the number of threads spawned to porcess depend on the configuraiton for consumers. You could have set this value to 1 in case you wanted just one message to be processed at one time & in this case the container would have spawned just one thread.
What are you doing? You are supposed to be reading this tiny ad!
the new thread boost feature brings a LOT of attention to your favorite threads