Sunday, June 22, 2003 04:08 PM
It would be too complex and innefficient for any app server to synchronize access across a cluster. So the answer is: No, the app server does not synchronize method access of any EJB across a cluster.
Rather, you need to specify the isolation level of the transaction. Isolation levels predate EJBs and are specified in JDBC when you start a transaction. If you are using entity beans, they are specified inside the deployment descriptor and handled automatically by the ejb container. Essentially, they dictate how isolated each transaction is to each other. To achieve something similar to java's synchronized method semantics, you would use the SERIALIZABLE isolation level. With this, only one thread at a time is allowed to access the database. This gives you the least amount of concurrency since all other transactions block until the current one commits. At the other end of the spectrum is the read uncommitted which gives you the least amount of isolation but also the most speed.
There's more to it and you can take a look at the jdbc api here.