Results 1 to 1 of 1
  1. #1
    Zamppa is offline Member
    Join Date
    Feb 2009
    Rep Power

    Default Behaviour of stop() and destroy()-methods

    Hello everyone!

    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...

Similar Threads

  1. AffinedTransform strange behaviour
    By Echilon in forum AWT / Swing
    Replies: 3
    Last Post: 12-11-2008, 09:58 AM
  2. Strange behaviour in swing
    By cbalu in forum AWT / Swing
    Replies: 1
    Last Post: 05-23-2008, 09:23 PM
  3. Replies: 0
    Last Post: 03-31-2008, 10:19 AM
  4. Applets (init, start, stop, destroy)
    By Java Tip in forum Java Tip
    Replies: 0
    Last Post: 12-12-2007, 10:57 AM
  5. Replies: 0
    Last Post: 09-28-2007, 12:51 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts