First of all, I don't think that class would work as written, since the 
singleton is not defined as an actual singleton and would cause infinite 
recursion until the JVM runs out of heap space.

However, to answer your underlying question, each instance has its own JVM. 
Therefore, the singleton pattern is not useful for synchronizing data 
across the entire application; you need to use Memcache and/or the 
Datastore for that.

On Tuesday, January 15, 2013 1:01:03 PM UTC-5, José Luis Montesinos 
González wrote:
>
>
> I only want to know a question. If I have a class like this:
>
> public class Example
> {
>     ArrayList<String> vector;
>
>     public Example singleton = new Example();
>     
>     private Example()
>     {
>         //Read data from BD and fill the vector. Example vector:  
> ["foo","voo","faa","vuu","vee"]
>     }    
>
>     public synchronized removeElement()
>     {
>         vector.remove(0);
>     }
>
>     public synchronized changeElement()
>     {
>         vector.set(0,"fii");
>     }
> }
>
> If there are multiple instances running and one of them executes the 
> method removeElement? What happens with the values of the other instance? 
> And if one of them executes the method changeElement?
>
> Thanks a lot.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Google App Engine" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/google-appengine/-/B2twZn0_4-4J.
To post to this group, send email to google-appengine@googlegroups.com.
To unsubscribe from this group, send email to 
google-appengine+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-appengine?hl=en.

Reply via email to