java - Collision of static variables for two applications in the same jvm -


i have applet application uses several static objects (and can not rid of them). application launched html page. browser creates single jvm amount of tabs , if open 2 tabs application, static variables shared both of them. both won't work correctly after this. we've tried use separate_jvm doesn't work in every browser.

is there other solution?

this test case demonstrates how static field in single class can have different values, in same jvm, when loading class 2 instances of classloader:

@test public void test() throws exception {      myloader customloader1 = new myloader();     myloader customloader2 = new myloader();      class<?> c1 = customloader1.loadclass(special_class_name);     class<?> c2 = customloader2.loadclass(special_class_name);      loadedclass o1 = (loadedclass) c1.newinstance();     loadedclass o2 = (loadedclass) c2.newinstance();      o1.setstaticpart(100d);     o2.setstaticpart(1d);      assertequals(100d, o1.getstaticpart());     assertequals(1d, o2.getstaticpart()); } 

how use custom classloader in applet leave exercise reader. :-)


Comments

Popular posts from this blog

How to mention the localhost in android -

php - Calling a template part from a post -

c# - String.format() DateTime With Arabic culture -