From 7620da85f161e52ce3e15f32e720270d052486a0 Mon Sep 17 00:00:00 2001 From: Govindass Date: Fri, 12 Feb 2021 12:43:57 +0200 Subject: [PATCH] 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 --- src/java/com/btk5h/skriptdb/SkriptDB.java | 4 ---- src/java/com/btk5h/skriptdb/skript/EffExecuteStatement.java | 2 +- 2 files changed, 1 insertion(+), 5 deletions(-) diff --git a/src/java/com/btk5h/skriptdb/SkriptDB.java b/src/java/com/btk5h/skriptdb/SkriptDB.java index 44b2328..055703a 100644 --- a/src/java/com/btk5h/skriptdb/SkriptDB.java +++ b/src/java/com/btk5h/skriptdb/SkriptDB.java @@ -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"); diff --git a/src/java/com/btk5h/skriptdb/skript/EffExecuteStatement.java b/src/java/com/btk5h/skriptdb/skript/EffExecuteStatement.java index 44f8ac6..bba8eeb 100644 --- a/src/java/com/btk5h/skriptdb/skript/EffExecuteStatement.java +++ b/src/java/com/btk5h/skriptdb/skript/EffExecuteStatement.java @@ -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 query; private Expression dataSource;