Hi Found this here: http://forum.java.sun.com/thread.jsp?forum=30&thread=34027 Initially sounded a bit weird, but probably is correct right? Just sounds a bit strange that two applets fire up 'seemingly independently', but then they affect each other like this. This is almost seems like a variable that should be synchronized, right? Cheers.
As a really simple experiment, create an applet with a public and static (and non-final) variable. Open up the applet in two separate browser processess. Change the value of the variable in one instance of the applet. When you read the value of the variable in the second instance of the applet, does it recognize that the value has changed? If not, then you are running two different VMs. If so, you are running a single, shared VM. I would bet, in this scenario, you will find that the two applets will not share the same VM. (Static variables are the key here since the classloader only needs to load a class, and its static variables, once.)
hi Jim well, it didn't sounded much weired 'coz if we know that class loader loads static fields with class and they remain in memory till the class is there... so if something is static in the applet and if the browser uses same JVM instance to run the applet multiple times then it will share that variable and you are correct in the prediction that "it has to be synchronized access" otherwise you might run into problems. the interesting thing is to observe what happens on different browsers and in various cases. Browsers, 1. Netscape 7 2. Netscape 4.7* 3. IE 4. Mozilla Cases, 1. mutlipe browser windows 2. same applet, twice on one page 3. opening an applet page, closing the browser window and open it again the new browser window... i bet browsers would proove themselves against us behaving differntly the important factor is- browsers uses caches for applet and all. so if u have a plug-in then u have to use option "x" (clear classloader cache) to make sure the applet is using the latest classes. now, when we close the browser window and open it again the browser may use the cache only to load the applet second time so we may want to use "x" before typing url again in the brwoser second time... if you have time please consider above cases and see what you get and let us know about it ... regards maulin
posted 17 years ago
btw that option "x" is in "Java Console" (if u run Sun JRE in the browser) in case u r unaware.. regards maulin