Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
The moose likes EJB and other Java EE Technologies and the fly likes Using a EJB with threading Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "Using a EJB with threading" Watch "Using a EJB with threading" New topic

Using a EJB with threading

William Ross

Joined: Jul 06, 2006
Posts: 12
As I understand it the ejb takes care of threading for us? What I am trying to do is syncronize a method so that only one thread can be using it at a time. However, I get an error when I try to use syncronize. What I think is happening is the ejb is running multiple instances of this method at a time due to threading. But I want only one flow of control within this method. Sorry if this sounds confusing; I can clarify more... thanks.
Scott Selikoff
Saloon Keeper

Joined: Oct 23, 2005
Posts: 3753

In J2EE, you generally should avoid any and all thread management. In particular, you should never spawn threads.

What do you need synchronized methods for? If it is for a static object, there are better solutions to manage singletons in a J2EE environment.

[OCA 8 Book] [Blog]
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
subject: Using a EJB with threading
It's not a secret anymore!