GAE/J starts as many JVM instances as required. Multiple JVMs ~
multiple Singletons.

On Apr 5, 4:48 pm, g3 insight <[email protected]> wrote:
> We are meeting one strange thing when we do testing on GAE.
> The problem is that we implemented a GameCenter class as below.
> It is a singleton class in system, but we found it always initialize
> multiple instances based on logs.
> Please check the source code and info log below.
> Could you explain why it happens and how to resolve it?
>
> Source Code:
> public class GameCenter implements IGameCenter {
>     static final long serialVersionUID = -1L;
>     private static GameCenter instance = null;
>     private long instanceNumber = -1;
>
>     private GameCenter() {
>         instanceNumber = System.currentTimeMillis();
>         initRoom();
>         hostClientProxy = new HostClientProxyImpl();
>         chatCenter = new ChatCenter(null);
>         log.info("GameCenter constructor---   :  " + instanceNumber);
>         dataVersion = 0;
>     }
>
>     public static synchronized GameCenter getInstance() {
>         if(instance == null){
>             instance =new GameCenter();
>         }
>         return instance;
>     }
>
> }
>
> Info Log in GAE:
> 04-05 07:29AM 47.910 GameCenter <init>: GameCenter constructor--- :
> 1270477784633
> 04-05 07:27AM 48.654 GameCenter <init>: GameCenter constructor--- :
> 1270477664172

-- 
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 [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/google-appengine-java?hl=en.

Reply via email to