Hi,

may we use the java keyword "synchronized" on a method of a SLSB to ensure that 
several statements get executed all together or not at all?

I have a method in a SLSB, which updates a counter kept in an Entity bean, if 
some condition is fulfilled.

Afterwards the counter is increased. I want to ensure the integrity of the 
counter. Because several threads can and will access the method.

What would you suggest?

This how the pseudo code block looks like:


  | 
  | public String methodDoesNotBelongToSLSinterface(EnityBeanWithCounter eb)
  | {
  | ...
  | ...
  | // make sure that no race condition can occur using 
  | synchronized(this)
  | {
  | statement1;
  | statement2;
  | ...
  | statementN;
  | // Increase counter if successful 
  | if (someCondition)
  |   eb.setCounter(eb.getCounter + 1);
  | }
  | ....
  | ....
  | }
  | 
  | 

View the original post : 
http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4084564#4084564

Reply to the post : 
http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4084564
_______________________________________________
jboss-user mailing list
jboss-user@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/jboss-user

Reply via email to