remove thread pool config option & Use CachedThreadPool to make sure all threads are used properly

CachedThreadPool automatically creates threads on demand and automatically deletes unused threads after 60 seconds of no usage, so we can remove config option
This commit is contained in:
Govindas 2021-02-12 12:43:57 +02:00
parent 05554a0043
commit 5a22864650
2 changed files with 1 additions and 5 deletions

View File

@ -73,10 +73,6 @@ public final class SkriptDB extends JavaPlugin {
}
try {
if (out == null) return;
out.write("# How many connections can be awaited for simultaneously, may be useful to increase if mysql database is hosted on a separate machine to account for ping.\n");
out.write("# If it is hosted within the same machine, set it to the count of cores your processor has or the count of threads your processor can process at once.\n");
out.write("thread-pool-size: " + (Runtime.getRuntime().availableProcessors() + 1) + "\n");
out.write("# Only change this if you wish to use a different driver than Java's default, like MariaDB driver.\n");
out.write("# If you use MariaDB, its driver is shaded together with skript-db, so you can just specify:" + "\"org.mariadb.jdbc.Driver\"" + ".\n");
out.write("sql-driver-class-name:" + "\"default\"" + "\n");

View File

@ -51,7 +51,7 @@ public class EffExecuteStatement extends Effect {
static String lastError;
private static final ExecutorService threadPool =
Executors.newFixedThreadPool(SkriptDB.getInstance().getConfig().getInt("thread-pool-size", 2));
Executors.newCachedThreadPool();
private Expression<String> query;
private Expression<HikariDataSource> dataSource;