Concept confusing between transaction isolation and synchronized


EJB design: Concept confusing between transaction isolation and synchronized

  1. Java provide keyword "synchronized" to avoid conflict access and its grain-level could be decided as you need except objects are dispersed in ditributed places.
    So has the transaction contains the same function?If it is,I don't know such idea is correct:if we need transaction within a bean object,we could use synchonized,if we need do transaction among serveral servers,we should use JTS.
  2. Hi
      Transactions are more concerned with backend ; I mean databases ; rather than the code.If you define a transation isolation level ; it will be used by the underlying database to restrict access to tables as defined .Synchronised also performs the same type of operations ; though on the code ; so that no two threads enter the code that u want to be threadsafe.
      Hope this helps
  3. Pankaj:
        I think the transaction represent an atomic business operation ,maybe include resources as database,port,file...,maybe not include resources but just only some business computation.I think synchonized is one of implementations of transation,but the oringinal target of synchronized is not for transaction,but for threadsafe.