Results 1 to 1 of 1
- 02-10-2009, 09:50 AM #1Member
- Join Date
- Feb 2009
- Rep Power
Behaviour of stop() and destroy()-methods
I'm one of the developers of a MMO type of game which has a applet based client application. In our application we use stop-method to save the game status and destroy method to check that the stop method ran succesfully, report any caught errors to server and send a logout message.
Recently I have noticed strange behaviour from these two methods. It seems like on some cases (about one in fifty) destroy()-method is called and the applet exits before stop()-method returns. In my effort to try and find the issue I have moved almost all the functionality in stop() method into a try/catch block but while the running stops within that block nothing is caught. When tracing the exact point where the running stops I get half a dozen different places, all of which are within that try / catch and while some of those spots could potentially crash none of them should cause the method to exit (say, a method call in try / catch with only stack trace print in catch block).
I have a few workarounds in my mind but first I'd really like to know what on earth is going on in here. Has anyone else noticed similar behaviour?
No matter, I found the error myself...
As it turns out in some cases Java decides to kill the thread that is running applet.stop() method while it's running and this causes a java.lang.ThreadDeath to be thrown. I discovered this by adding a catch for Throwables as well as Exceptions in the stop method, causing the method to return immediately without any trace of error. How nice of Sun to have such a little feature in the jvm...
Last edited by Zamppa; 02-10-2009 at 12:03 PM. Reason: Found the error...
- By Echilon in forum AWT / SwingReplies: 3Last Post: 12-11-2008, 09:58 AM
- By cbalu in forum AWT / SwingReplies: 1Last Post: 05-23-2008, 09:23 PM
- By Java Tip in forum Java TipReplies: 0Last Post: 03-31-2008, 10:19 AM
- By Java Tip in forum Java TipReplies: 0Last Post: 12-12-2007, 10:57 AM
- By JavaBean in forum Java TipReplies: 0Last Post: 09-28-2007, 12:51 PM