• Post Reply Bookmark Topic Watch Topic
  • New Topic

wait() & notify() and EJB restrictions  RSS feed

 
Paul Rhoades
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have read the EJB restrictions regarding the use of threading but am still unclear as to what I can and cannot do. In particular I have a singleton within my system that is accessed by multiple EJB's, so the questions are:
a) Can I synchronise the methods of the Singleton
b) Within the singleton I have pooled resource, I want to add a wait/notify strategy for the EJBs to acquire/release these, is this allowed?
Regards
Paul.
 
Chris Mathews
Ranch Hand
Posts: 2712
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Strictly speaking, what you suggest would be breaking the EJB Spec. It doesn't matter that the code is in a different class, because it still executes within the context of the EJB.
Despite that warning, I have two comments:
1) Containers typically do not enforce these areas of the specification, so your code should work.
2) Sometimes you have to break the rules...
I am not saying to use or not use the solution you suggest, because I don't know enough about your problem. I would give it some more thought to see if there wasn't another solution.
Why not post the problem that you are ultimately trying to solve? Someone here may be able to give a better alternative.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!