Urgent - JVM API

Hi,

How can I find out programmatically, if an instance of my applet is already running in the JVM? Does the JVM expose any such API?

The problem is as such. I have an applet that runs in a browser. The classes that if refers to are all singleton. Now if a user opens a new browser using File->New (ie new thread), then my singleton classes fail. Hence I wanted to query the JVM to know if an instance of the applet is already running. Is there a better solution to this problem other than disabling the browser menu bar.

Thanx.

[563 byte] By [whitematter] at [2007-9-26 5:24:26]
# 1
Why can't you just fix your singleton so it doesn't fail?
jschell at 2007-6-29 19:31:44 > top of Java-index,Java HotSpot Virtual Machine,Specifications...
# 2
When I said Singleton fails, I meant that my logic of using singleton classes fails. And it is not feasible for me to change that logic now. So I need to make sure that I have only 1 instance of the applet running under one JVM.thanks
whitematter at 2007-6-29 19:31:44 > top of Java-index,Java HotSpot Virtual Machine,Specifications...
# 3

>1 instance of the applet running under one JVM

Pretty sure that isn't possible. I believe (asking on a gui board might confirm this) that different class loaders are used in at least one browser. That means multiple applets will have multiple singletons which will not know about each other.

I don't see anyway to find out about other class loaders so one couldn't use that to find them.

You could have the applet open a socket server. If a second applet runs it will try to connect and will fail so it would exit.

jschell at 2007-6-29 19:31:44 > top of Java-index,Java HotSpot Virtual Machine,Specifications...