diff --git a/ArtificialAutism/src/main/java/PresentationLayer/DiscordHandler.java b/ArtificialAutism/src/main/java/PresentationLayer/DiscordHandler.java index 564b8b46..b8999dc0 100644 --- a/ArtificialAutism/src/main/java/PresentationLayer/DiscordHandler.java +++ b/ArtificialAutism/src/main/java/PresentationLayer/DiscordHandler.java @@ -20,6 +20,8 @@ import java.net.*; import java.sql.SQLException; import java.util.ArrayList; import java.util.List; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; /** @@ -87,6 +89,7 @@ public class DiscordHandler extends ListenerAdapter { private static StanfordCoreNLP stanfordCoreNLP; private static Datahandler datahandler; private static StanfordCoreNLP stanfordCoreNLPSentiment; + private static ExecutorService executorService = Executors.newFixedThreadPool(2); //TODO add python program that edits the java code. python program just adds test if statements on //variables until the tests pass @@ -168,11 +171,13 @@ public class DiscordHandler extends ListenerAdapter { } } else { final String contentF = content; - //these should be able to run on their own. - new Thread(() -> { - String strF = datahandler.trimString(contentF); - datahandler.getResponseFutures(strF, stanfordCoreNLP, stanfordCoreNLPSentiment); - }).start(); + executorService.execute(new Runnable() { + @Override + public void run() { + String strF = datahandler.trimString(contentF); + datahandler.getResponseFutures(strF, stanfordCoreNLP, stanfordCoreNLPSentiment); + } + }); } } }