added threadpool to handle secondary processes. Should max be two threads and the main thread in use now
This commit is contained in:
parent
6006f50bcb
commit
e9969f836e
@ -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
|
||||||
|
public void run() {
|
||||||
String strF = datahandler.trimString(contentF);
|
String strF = datahandler.trimString(contentF);
|
||||||
datahandler.getResponseFutures(strF, stanfordCoreNLP, stanfordCoreNLPSentiment);
|
datahandler.getResponseFutures(strF, stanfordCoreNLP, stanfordCoreNLPSentiment);
|
||||||
}).start();
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user