aboutsummaryrefslogtreecommitdiff
path: root/juick-www/src/main/java/com/juick/www/Main.java
diff options
context:
space:
mode:
Diffstat (limited to 'juick-www/src/main/java/com/juick/www/Main.java')
-rw-r--r--juick-www/src/main/java/com/juick/www/Main.java12
1 files changed, 10 insertions, 2 deletions
diff --git a/juick-www/src/main/java/com/juick/www/Main.java b/juick-www/src/main/java/com/juick/www/Main.java
index e3457323..d8096ff4 100644
--- a/juick-www/src/main/java/com/juick/www/Main.java
+++ b/juick-www/src/main/java/com/juick/www/Main.java
@@ -37,6 +37,8 @@ import java.net.Socket;
import java.net.URLEncoder;
import java.util.Objects;
import java.util.Properties;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
/**
*
@@ -64,6 +66,7 @@ public class Main extends HttpServlet implements Stream.StreamListener {
SignUp signup = new SignUp();
Settings settings = new Settings();
RSS rss = new RSS();
+ ExecutorService executorService = Executors.newSingleThreadExecutor();
@Override
public void init() throws ServletException {
@@ -98,8 +101,14 @@ public class Main extends HttpServlet implements Stream.StreamListener {
}
}
+ @Override
+ public void destroy() {
+ executorService.shutdownNow();
+ super.destroy();
+ }
+
public void setupXmppComponent(final JID componentJid, final String password) {
- Thread thr = new Thread(() -> {
+ executorService.submit(() -> {
try {
Socket socket = new Socket("localhost", 5347);
xmpp = new StreamComponent(componentJid, socket.getInputStream(), socket.getOutputStream(), password);
@@ -109,7 +118,6 @@ public class Main extends HttpServlet implements Stream.StreamListener {
log("XMPP is not initialized");
}
});
- thr.start();
}
@Override