2 Replies Latest reply on Feb 14, 2013 12:08 PM by markaddleman

    Java Threading and Memory Model versus Translators

    markaddleman

      I hope to gain a better understanding of how threading and memory model issues affect translators.  To kick the conversation off:

       

      For non-reusable executions that don't use DataNotAvailable (vanilla executions), are all of the execution's lifecycle methods (execute, next, close, etc) called on the same thread? 

       

      Is it true that the only time an execution must ensure that its state is consistent across threads is when it throws DataNotAvailable because it could be restarted on a different thread?

        • 1. Re: Java Threading and Memory Model versus Translators
          shawkins

          > For non-reusable executions that don't use DataNotAvailable (vanilla executions), are all of the execution's lifecycle methods (execute, next, close, etc) called on the same thread?

           

          If they are forkable and not under a transaction then no they won't necessary be accessed by the same thread as assinging a thread for the lifetime of the work could lead to the exhaustion of the thread pool.

           

          > Is it true that the only time an execution must ensure that its state is consistent across threads is when it throws DataNotAvailable because it could be restarted on a different thread?

           

          Idon't recall having an explicit single lock acting as a read barrier even for normal access by multiple threads.  There is lots of other volatile/synchronized access that may incidentially cause consistency, but I'll have to look at this some more to see if adding synchronized to ConnectorWorkItem execute/close is needed.

          • 2. Re: Java Threading and Memory Model versus Translators
            markaddleman

            Thanks for the info.  I'll double check out translators for memory model problems.

             

            Just to offer an idea for future : provide a delegating translator that wraps the delegate in synchronized methods for convenience.  Optionally,translators may not use that delegating xlator for performance reasons.