aboutsummaryrefslogtreecommitdiff
path: root/core/src/main/java/fi
diff options
context:
space:
mode:
authorJarno Elonen <elonen@iki.fi>2015-08-08 21:48:01 +0300
committerJarno Elonen <elonen@iki.fi>2015-08-08 21:48:01 +0300
commit9e659197ebe52fa61801c20b913d666087f98eb4 (patch)
tree8f376143fc643f500db59a4de2cf03307eaf4718 /core/src/main/java/fi
parent33cf28e07464f3a5586ebc44299ce5fedf0af83b (diff)
downloadnanohttpd-9e659197ebe52fa61801c20b913d666087f98eb4.tar.gz
Added option to start server in non-deamon thread. Closes #212
Diffstat (limited to 'core/src/main/java/fi')
-rw-r--r--core/src/main/java/fi/iki/elonen/NanoHTTPD.java13
1 files changed, 11 insertions, 2 deletions
diff --git a/core/src/main/java/fi/iki/elonen/NanoHTTPD.java b/core/src/main/java/fi/iki/elonen/NanoHTTPD.java
index d7f34c7..9a37bad 100644
--- a/core/src/main/java/fi/iki/elonen/NanoHTTPD.java
+++ b/core/src/main/java/fi/iki/elonen/NanoHTTPD.java
@@ -1920,10 +1920,12 @@ public abstract class NanoHTTPD {
*
* @param timeout
* timeout to use for socket connections.
+ * @param daemon
+ * start the thread daemon or not.
* @throws IOException
* if the socket is in use.
*/
- public void start(final int timeout) throws IOException {
+ public void start(final int timeout, boolean daemon) throws IOException {
if (this.sslServerSocketFactory != null) {
SSLServerSocket ss = (SSLServerSocket) this.sslServerSocketFactory.createServerSocket();
ss.setNeedClientAuth(false);
@@ -1935,7 +1937,7 @@ public abstract class NanoHTTPD {
ServerRunnable serverRunnable = createServerRunnable(timeout);
this.myThread = new Thread(serverRunnable);
- this.myThread.setDaemon(true);
+ this.myThread.setDaemon(daemon);
this.myThread.setName("NanoHttpd Main Listener");
this.myThread.start();
while (!serverRunnable.hasBinded && serverRunnable.bindException == null) {
@@ -1953,6 +1955,13 @@ public abstract class NanoHTTPD {
}
/**
+ * Starts the server (in setDaemon(true) mode).
+ */
+ public void start(final int timeout) throws IOException {
+ start(timeout, true);
+ }
+
+ /**
* Stop the server.
*/
public void stop() {