jdk/src/jdk.httpserver/share/classes/sun/net/httpserver/ServerImpl.java
changeset 27720 aa3983c8fbee
parent 25859 3317bb8137f4
child 27779 e269428daa22
--- a/jdk/src/jdk.httpserver/share/classes/sun/net/httpserver/ServerImpl.java	Thu Nov 06 13:29:36 2014 -0800
+++ b/jdk/src/jdk.httpserver/share/classes/sun/net/httpserver/ServerImpl.java	Sat Nov 15 18:26:29 2014 +0000
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -82,6 +82,7 @@
 
     private Timer timer, timer1;
     private Logger logger;
+    private Thread dispatcherThread;
 
     ServerImpl (
         HttpServer wrapper, String protocol, InetSocketAddress addr, int backlog
@@ -141,9 +142,9 @@
         if (executor == null) {
             executor = new DefaultExecutor();
         }
-        Thread t = new Thread (dispatcher);
+        dispatcherThread = new Thread (dispatcher);
         started = true;
-        t.start();
+        dispatcherThread.start();
     }
 
     public void setExecutor (Executor executor) {
@@ -205,6 +206,12 @@
         if (timer1Enabled) {
             timer1.cancel();
         }
+        try {
+            dispatcherThread.join();
+        } catch (InterruptedException e) {
+            Thread.currentThread().interrupt();
+            logger.log(Level.FINER, "ServerImpl.stop: ", e);
+        }
     }
 
     Dispatcher dispatcher;