I am reading the following 
http://code.google.com/appengine/docs/java/datastore/transactions.html



Take the following code example.


import javax.jdo.Transaction;

import ClubMembers;   // not shown

// ...
        // PersistenceManager pm = ...;

        Transaction tx = pm.currentTransaction();

        try {
            tx.begin();

            ClubMembers members = pm.getObjectById(ClubMembers.class,
"k12345");
            members.incrementCounterBy(1);
            pm.makePersistent(members);

            tx.commit();
        } finally {
            if (tx.isActive()) {
                tx.rollback();
            }
        }

(Now, I assume there will be only one servlet instance in entire web
environment. Multiple thread will be spawn to access the code in the
one servlet instance, for multiple web request.)

(1) Does this mean, any code block in between tx.begin and tx.commit,
there will be only one thread can access at a time? Is the tx.being
and tx.commit is similar to syncrhonized keyword?

(2) For incrementCounterBy, do we have the explicitly declare the
method header as synchronized?

(3) If two thread execute pm.getObjectById(ClubMembers.class,
"k12345");, are they going to get the same object instance?

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Google App Engine for Java" group.
To post to this group, send email to google-appengine-java@googlegroups.com
To unsubscribe from this group, send email to 
google-appengine-java+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/google-appengine-java?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to