• Post Reply Bookmark Topic Watch Topic
  • New Topic

Concurrency in J2EE Container

 
Stephen Watson
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am charged with refactoring a J2EE application (WebLogic 10) and have come across code that creates threads (extend java.lang.Thread). I seem to remember from my early reading on J2EE that it is bad practice to spawn your own threads in a J2EE container, and also that there are better ways of achieving concurrency.

Question 1: Why are threads in a container problematic and what kind of problems can they cause?

Question 2: What are the best practices for achieving concurrency?
 
kri shan
Ranch Hand
Posts: 1480
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please check java.util.concurrent package API methods.
 
Stephen Watson
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
java.util.concurrent is precisly what the J2EE practices advise against because new threads will be outside the control of the container. Thus my question.
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What type of container do you mean when you say "J2EE" container? An EJB container? The specification explicitly mandates you should never spawn threads from an EJB. A Servlet container is a different matter.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!