<html>
  <head>
    <meta content="text/html; charset=ISO-8859-1"
      http-equiv="Content-Type">
  </head>
  <body bgcolor="#FFFFFF" text="#000000">
    <div class="moz-cite-prefix">Hi Anurag, <br>
      <br>
      Sorry for the late answer. <br>
      <br>
      The reason that SSCS.execute() is synchronized is that you could
      otherwise encounter race conditions. <br>
      <br>
      It's been a while since I've looked at that code, but if I
      remember correctly, it has to do with what execute() really does,
      which is: <br>
      <br>
      <tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; transactionOwner = txm.begin();</tt><tt><br>
      </tt><tt><br>
      </tt><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; registerRollbackSync();</tt><tt><br>
      </tt><tt><br>
      </tt><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; persistenceContext.joinTransaction();</tt><tt><br>
      </tt><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; persistenceContext.persist( this.sessionInfo
        );</tt><tt><br>
      </tt><tt><br>
      </tt><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; txm.commit( transactionOwner );</tt><br>
      <br>
      If you had threads concurrently executing this code with a JTA
      transaction (on the same session), it's possible that, for
      example, this could happen: <br>
      <br>
      Thread A: txm.begin()<br>
      Thread B: txm.begin() // no-op because _not_ the txOwner!<br>
      Thread B: registerRollbackSync(), joinTransaction(), persist(), <br>
      Thread B: txm.commit() // no-op, because _not_ the txOwner!<br>
      Thread A: registerRollbackSync(), joinTransaction(), persist(), <br>
      Thread B: <b>txm.commit()</b> // overwrites the persist from
      Thread B, even though thread B should have finished 2nd. <br>
      <br>
      Also, there are also race conditions in which commits will fail
      because a thread that does not own the transaction will commit
      after the tx has been closed. <br>
      <br>
      I'm pretty sure that that's the problem -- does that make sense? <br>
      <br>
      <br>
      Marco<br>
      <br>
      07-12-12 08:55, Anurag Aggarwal:<br>
    </div>
    <blockquote
      cite="mid:919EE647-293C-4979-947D-E37590EC7B60@intalio.com"
      type="cite">Hi,
      <div><br>
      </div>
      <div>I am using jbpm and drools at Intalio and recently we were
        looking into performance, and found an issue that in persistence
        the following class</div>
      <div><span style="font-family: 'Lucida Grande'; font-size: 9px; ">org.drools.persistence.</span><span
          style="font-family: 'Lucida Grande'; font-size: 9px; ">SingleSessionCommandService</span></div>
      <div><span style="font-family: 'Lucida Grande'; font-size: 9px; "><br>
        </span></div>
      <div><span style="font-family: 'Lucida Grande'; font-size: 9px; ">has
          method execute() which is synchronized and is entry point to
          all jbpm functionality</span></div>
      <div><span style="font-family: 'Lucida Grande'; font-size: 9px; "><br>
        </span></div>
      <div><span style="font-family: 'Lucida Grande'; font-size: 9px; ">We
          were trying to update many process instances at same time and
          seems because of above they are updated one after another and
          not in parallel</span></div>
      <div><span style="font-family: 'Lucida Grande'; font-size: 9px; "><br>
        </span></div>
      <div><span style="font-family: 'Lucida Grande'; font-size: 9px; ">I
          wanted to understand the reason for this method being
          synchronized and what would be required to make it
          non-synchronized</span></div>
      <div><span style="font-family: 'Lucida Grande'; font-size: 9px; "><br>
        </span></div>
      <div><span style="font-family: 'Lucida Grande'; font-size: 9px; ">I
          would be thankful for any advice/help&nbsp;</span></div>
      <div><span style="font-family: 'Lucida Grande'; font-size: 9px; "><br>
        </span></div>
      <div><span style="font-family: 'Lucida Grande'; font-size: 9px; ">Regards,</span></div>
      <div><span style="font-family: 'Lucida Grande'; font-size: 9px; ">Anurag</span></div>
      <br>
      <fieldset class="mimeAttachmentHeader"></fieldset>
      <br>
      <pre wrap="">_______________________________________________
jbpm-dev mailing list
<a class="moz-txt-link-abbreviated" href="mailto:jbpm-dev@lists.jboss.org">jbpm-dev@lists.jboss.org</a>
<a class="moz-txt-link-freetext" href="https://lists.jboss.org/mailman/listinfo/jbpm-dev">https://lists.jboss.org/mailman/listinfo/jbpm-dev</a>
</pre>
    </blockquote>
    <br>
    <br>
    <pre class="moz-signature" cols="72">-- 
jBPM/Drools developer
Utrecht, the Netherlands</pre>
  </body>
</html>