From 72abd7c5f31f2db7606ef8ca6b38e09a899de51d Mon Sep 17 00:00:00 2001 From: Vitaly Takmazov Date: Tue, 26 Jan 2016 21:03:36 +0300 Subject: CachedThreadPool for s2s --- src/main/java/com/juick/xmpp/s2s/ConnectionListener.java | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/juick/xmpp/s2s/ConnectionListener.java b/src/main/java/com/juick/xmpp/s2s/ConnectionListener.java index f29b8d09..314be116 100644 --- a/src/main/java/com/juick/xmpp/s2s/ConnectionListener.java +++ b/src/main/java/com/juick/xmpp/s2s/ConnectionListener.java @@ -3,6 +3,8 @@ package com.juick.xmpp.s2s; import java.io.IOException; import java.net.ServerSocket; import java.net.Socket; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; /** * @@ -10,6 +12,8 @@ import java.net.Socket; */ public class ConnectionListener implements Runnable { + ExecutorService executorService = Executors.newCachedThreadPool(); + @Override public void run() { try { @@ -18,8 +22,7 @@ public class ConnectionListener implements Runnable { Socket sock = listener.accept(); ConnectionIn conn = new ConnectionIn(sock); XMPPComponent.addConnectionIn(conn); - Thread t = new Thread(conn); - t.start(); + executorService.submit(conn); } } catch (IOException e) { System.out.println("IOException on socket listen: " + e.toString()); -- cgit v1.2.3