简体   繁体   中英

What is the proper way to handle the closing of a java applet?

We have a java applet that runs windowed outside the browser window. I always assumed that by clicking the X to close the window (or right clicking on the task bar and selecting close) was all you needed to do to close an applet.

However, it turns out that when closed this way, our applet crashes Safari (in both Mac and Windows) every time.

Is there something I am supposed to be doing in the code when an applet closes? The first culprit that comes to mind in the code is a class/library that does a socketed connection for Jabber/XMPP.

Use the destroy() life cycle callback in your applet to dispose of all resources that you have open (threads, sockets etc). What happens if you don't might vary per browser, but in my experience (mainly Firefox) threads usually keep running, forcing a restart of the browser in order to reload your app. Not slick. I haven't seen a crash due to this, but disposing of resources is a good practice anyway.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM