aboutsummaryrefslogtreecommitdiff
path: root/juick-www/src/main/java/com/juick/www
diff options
context:
space:
mode:
authorGravatar Vitaly Takmazov2016-08-01 16:43:39 +0300
committerGravatar Vitaly Takmazov2016-08-01 16:43:39 +0300
commit2262c9c81fee46f21b3f1f2f3441cdfd41cb1f64 (patch)
tree6df630737e29f98c5baa6378f790026b32b5ee19 /juick-www/src/main/java/com/juick/www
parent17511f33332fd298779765b49a4817a4b2503c45 (diff)
www: Thread -> ExecutorService
Diffstat (limited to 'juick-www/src/main/java/com/juick/www')
-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