Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8213439
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T11:07:07+00:00 2026-06-07T11:07:07+00:00

I just synchronized my java code to avoid multiple access to the same List.

  • 0

I just synchronized my java code to avoid multiple access to the same List. Here it is my code:

List<Category> list = Collections.synchronizedList(listCat); 
..
pm.currentTransaction().begin();
..
synchronized (list) {
    for (Category category : list) {
        category.setKey(null);
        tempUser.addToCategories(category);
    }
}
..
pm.currentTransaction().commit();

.. but I continue to get

java.util.ConcurrentModificationException: too much contention on these datastore entities. please try again.
at com.google.appengine.api.datastore.DatastoreApiHelper.translateError(DatastoreApiHelper.java:39)
at com.google.appengine.api.datastore.DatastoreApiHelper$1.convertException(DatastoreApiHelper.java:76)
at com.google.appengine.api.utils.FutureWrapper.get(FutureWrapper.java:106)
at com.google.appengine.api.utils.FutureWrapper.get(FutureWrapper.java:90)
at com.google.appengine.api.utils.FutureWrapper.get(FutureWrapper.java:90)
at com.google.appengine.api.datastore.FutureHelper.getInternal(FutureHelper.java:72)
at com.google.appengine.api.datastore.FutureHelper.quietGet(FutureHelper.java:33)
at com.google.appengine.api.datastore.TransactionImpl.commit(TransactionImpl.java:116)
at org.datanucleus.store.appengine.jdo.DatastoreJDOTransaction.commit(DatastoreJDOTransaction.java:68)
at (the row where the transaction is committed)

.. when different instances access to that list.
Is there a way to avoid that? I mean a different way from the one specified here:
Uses for Transactions.

I use JDO 2.3, but I don’t think it affects in anyway this behaviour

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T11:07:09+00:00Added an answer on June 7, 2026 at 11:07 am

    GAE transactions don’t do locking: they use optimistic concurrency control, meaning if multiple transactions change same entity group the first will succeed the others will fail and will need to be retried.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I just saw the code of contains method in java.util.Hashtable.java. It has a loop
Just noticed in ByteArrayOutputStream , the toByteArray() is declared as, public synchronized byte toByteArray()[];
just wondering if there is a way to reduce the amount of code needed
I am just playing around with threads in java. I have a class which
I'm just getting started with Threads in Java so this might be a basic
I've just been messing around with threads in Java to get my head around
If variables in Java are accessed from multiple threads, one must ensure that they
In Java, Volatile and synchronized make multithreads can work together and understand each others
programmer mates. I was testing java threading capabilities with a very simple code (or
I've been searching about the possibility of propagate a JTA transaction from Java code

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.