Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [jetty-users] Closing a jaxa.websocket.WebSocketContainer in Jetty 9.1

On 07/01/2014 11:17, Kasper Nielsen wrote:
I do have users that might not remember to close the library in a finally block.
Which is needed, for example, if some exception is thrown.

Maybe kick off another thread from the main thread that does a join on the main thread followed by System.exit? Something like this:

  class Terminator extends Thread {
    private Thread creator;
    public Terminator() {
      creator = Thread.currentThread();
    }
    public void run() {
      while (creator.isAlive()) {
        try {
          creator.join();
        }
        catch Exception e) { }
      }
      System.exit(0);
    }
  }

--
John English


Back to the top