If a Java Swing application hosted on a server machine has a singleton, so when multiple clients access to that Swing app on that server, I assume each client's local machine will use its own JVM to run that app, correct? If that's the case, each local machine will create ONE singleton in its own JVM. So, that means there're a lot of singletons out there, and that defeat the purpose of using a singleton in the Swing app on the server trying to control how many instances to be created for a particular class, right?
So, my question is how to prevent that? Is it possible for multiple cients use the same singleton provided/created on the server JVM?
Well, the Swing App on the server side, how does the client's see the GUI, doesn't it only display on the Server. It is actually pretty easy to keep a Singleton on the Server. Just have the server pass back the one instance to all the clients, the instance stays on the server, you only have a Proxy object on the clients that make calls to the one object on the server.