how to finish a java applet when I change of url in IExplorer

D

davidgrs

I have a problem with a java applet that has inside a thread, when I
change of page, the java applet is still runing, and then when I load
another page tha cotaints this java applet, I have two instances
running in my internet explorer.

I am aware of this because my java application uses tcp sockets
communications, and the tcp activity is still alive when I changed of
paged in the Internet Explorer.

Thanks a lot.


David Rodriguez
 
S

Sebastian Scheid

davidgrs said:
I have a problem with a java applet that has inside a thread, when I
change of page, the java applet is still runing, and then when I load
another page tha cotaints this java applet, I have two instances
running in my internet explorer.

I am aware of this because my java application uses tcp sockets
communications, and the tcp activity is still alive when I changed of
paged in the Internet Explorer.

Did you override the stop()-method? You should stop the communication and
the thread there. Be aware that stop is called when loading another page,
quitting the browser or minimizing the browser window. When displaying the
page again (by jumping back in history or restoring the window) start() is
called. Test this behaviour with different browsers. Perhaps you can use the
destroy()-method, too.

Regards
Sebastian
 
A

Andrew Thompson

Did you override the stop()-method? You should stop the communication and
the thread there. Be aware that stop is called when loading another page,
quitting the browser or minimizing the browser window.

Be aware that while compatible browser/VM combinations are
*supposed* to call the stop() method on page exit, many don't.

You can never absolutely rely on stop() being called.

To the OP. You might be able to get around this problem by
applying the singleton design pattern here. Only one instance
of the applet will exit in any one VM.

Of course, if a browser choses to load mulitple VM's, all bets are
off, and you are better off to check for the original socket being
occupied to trigger an error/information message.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,768
Messages
2,569,574
Members
45,051
Latest member
CarleyMcCr

Latest Threads

Top