This week's book giveaway is in the Kotlin forum.
We're giving away four copies of Kotlin in Action and have Dmitry Jemerov & Svetlana Isakova on-line!
See this thread for details.
Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

How beans in EJB3.0 are threadsafe?  RSS feed

 
pradeep singh
Ranch Hand
Posts: 339
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi
How beans in EJB3.0 are threadsafe?
 
Joe Harry
Ranch Hand
Posts: 10128
3
Eclipse IDE Mac PPC Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can you say how your servlets are thread safe?
 
pradeep singh
Ranch Hand
Posts: 339
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Servlets are thread safe because web-container creates only one instance of each servlets but when a client requests then container creates a thread to access this servlet instance.
 
Ulf Dittmer
Rancher
Posts: 42972
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Servlets are thread safe because web-container creates only one instance of each servlets but when a client requests then container creates a thread to access this servlet instance.

In other words, servlets are not thread-safe, unless the developer takes care to make them so.
 
E Lievaart
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The EJB container ensures that there is always only 1 Thread accessing an EJB.
Different threads may be directed to an EJB, but not simultaneously.
This is why you are not allowed to create threads or use synchronization.
It is the turf of the container.
Basically EJB's are similar to the Servlet single thread model.

Of course this doesn't relieve the programmer of any concurrent considerations.
For example:
Don't use instance variables (except resources) in stateless session beans.
 
pradeep singh
Ranch Hand
Posts: 339
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi
Thankx
It was my misunderstanding .I know servlets by default are not threadsafe but developer can make it if require.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!