Design pattern to handle threading in J2EE context?

Discussions

General J2EE: Design pattern to handle threading in J2EE context?

  1. Design pattern to handle threading in J2EE context? (1 messages)

    You have a standard model 2 (jsp/servlet/ejb model) where the backend process, either servlet or ejb, does a series of jobs. Let assume there are 3 jobs, A, B and C. A takes 5 seconds, B takes 10 and C takes 15. None of the jobs are dependent upon each other and do not need to be run serially. The front end however needs data from all 3 jobs but you want the jobs to run concurrently so that the longest amount of time you would have to wait would be 15 seconds. How would one go about handling this? I'm not sure about threading at the servlet level but I know it is not recommended at the EJB level.

    Any info, tips, discussio would be appreciated.
    -Dat
  2. "Any servlet can create a thread during its life-time. Because when your inside a servlet you have full power of the JVM at your fingertips. However, with the creation of threads also comes the responsibility of carrying out its timely destruction. In the servlet model, the destroy() callback provides a useful place for checking and removing secondary threads created by your servlets."
    For more information see:
    http://www.acknowledge.co.uk/ejava/servlet_seminar/servlets/threading.html

    HTH
    /Henrik Engstrom