Win a copy of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

How do EJB deal with multi-thread?  RSS feed

 
George Toronto
Ranch Hand
Posts: 78
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, all,
I am comfused by the multi-thread problems about EJB. How do the EJB deal with multi-threads suchas deal with the sychronization problems in an online banking project.
Thankx
george
 
Jim Baiter
Ranch Hand
Posts: 532
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You are not allowed to spawn threads from within a bean - the spec forbids it. Some vendors may let you get away with it but it is very ill advised. You can have a multithreaded client/servlet accessing a pool of session beans concurrently. This is usually the way most people handle it. Also, you can create RMI objects which are multithreaded, bind them to a JNDI name and use these. File I/O from beans is not allowed either.
 
George Toronto
Ranch Hand
Posts: 78
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi,jim
thanx. could you tell me where i can get the specification of EJB and which section your answer is?
other other hand, u know, EJB is based on RMI. RMI can have multithreaded properties, why does it disappare in ejb? Moreover, how is the multithread implemented in RMI? We should set the XXXImpl class extend Runable or Thread, but who manages the threads?
best rgds
george
 
Jim Baiter
Ranch Hand
Posts: 532
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Just go to java.sun.com - they have a search engine.
 
Peter den Haan
author
Ranch Hand
Posts: 3252
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by George Toronto:
RMI can have multithreaded properties, why does it disappare in ejb?

Because your client isn't calling the EJB directly. The EJB container wraps around your EJB and serialises access. It also makes sure it's activated if necessary, manages transactions and does all the other housekeeping chores.
- Peter

 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!