added threadpool to handle secondary processes. Should max be two threads and the main thread in use now

This commit is contained in:
christian 2021-12-06 18:38:15 +01:00
parent 6006f50bcb
commit e9969f836e

View File

@ -20,6 +20,8 @@ import java.net.*;
import java.sql.SQLException; import java.sql.SQLException;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; 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 StanfordCoreNLP stanfordCoreNLP;
private static Datahandler datahandler; private static Datahandler datahandler;
private static StanfordCoreNLP stanfordCoreNLPSentiment; 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 //TODO add python program that edits the java code. python program just adds test if statements on
//variables until the tests pass //variables until the tests pass
@ -168,11 +171,13 @@ public class DiscordHandler extends ListenerAdapter {
} }
} else { } else {
final String contentF = content; final String contentF = content;
//these should be able to run on their own. executorService.execute(new Runnable() {
new Thread(() -> { @Override
String strF = datahandler.trimString(contentF); public void run() {
datahandler.getResponseFutures(strF, stanfordCoreNLP, stanfordCoreNLPSentiment); String strF = datahandler.trimString(contentF);
}).start(); datahandler.getResponseFutures(strF, stanfordCoreNLP, stanfordCoreNLPSentiment);
}
});
} }
} }
} }