diff --git a/L2J_Mobius_1.0_Ertheia/java/com/l2jmobius/commons/concurrent/IThreadPoolInitializer.java b/L2J_Mobius_1.0_Ertheia/java/com/l2jmobius/commons/concurrent/IThreadPoolInitializer.java deleted file mode 100644 index 43cb09350f..0000000000 --- a/L2J_Mobius_1.0_Ertheia/java/com/l2jmobius/commons/concurrent/IThreadPoolInitializer.java +++ /dev/null @@ -1,24 +0,0 @@ -/* - * This file is part of the L2J Mobius project. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package com.l2jmobius.commons.concurrent; - -public interface IThreadPoolInitializer -{ - int getScheduledThreadPoolSize(); - - int getThreadPoolSize(); -} diff --git a/L2J_Mobius_1.0_Ertheia/java/com/l2jmobius/commons/concurrent/ThreadPool.java b/L2J_Mobius_1.0_Ertheia/java/com/l2jmobius/commons/concurrent/ThreadPool.java index b56ca136e6..6473b38b06 100644 --- a/L2J_Mobius_1.0_Ertheia/java/com/l2jmobius/commons/concurrent/ThreadPool.java +++ b/L2J_Mobius_1.0_Ertheia/java/com/l2jmobius/commons/concurrent/ThreadPool.java @@ -29,6 +29,8 @@ import java.util.concurrent.atomic.AtomicInteger; import java.util.logging.Logger; import java.util.stream.Stream; +import com.l2jmobius.Config; + /** * @author _dev_ (savormix) * @author NB4L1 @@ -40,15 +42,16 @@ public final class ThreadPool private static ScheduledThreadPoolExecutor SCHEDULED_THREAD_POOL_EXECUTOR; private static ThreadPoolExecutor THREAD_POOL_EXECUTOR; - public static void initThreadPools(IThreadPoolInitializer initializer) throws Exception + public static void init() throws Exception { if ((SCHEDULED_THREAD_POOL_EXECUTOR != null) || (THREAD_POOL_EXECUTOR != null)) { throw new Exception("The thread pool has been already initialized!"); } - SCHEDULED_THREAD_POOL_EXECUTOR = new ScheduledThreadPoolExecutor(initializer.getScheduledThreadPoolSize(), new PoolThreadFactory("L2JU-SP-", Thread.NORM_PRIORITY)); - THREAD_POOL_EXECUTOR = new ThreadPoolExecutor(initializer.getThreadPoolSize(), initializer.getThreadPoolSize(), 1, TimeUnit.MINUTES, new LinkedBlockingQueue<>(), new PoolThreadFactory("L2JU-IT-", Thread.NORM_PRIORITY)); + SCHEDULED_THREAD_POOL_EXECUTOR = new ScheduledThreadPoolExecutor(Config.SCHEDULED_THREAD_POOL_COUNT != -1 ? Config.SCHEDULED_THREAD_POOL_COUNT : Runtime.getRuntime().availableProcessors() * Config.THREADS_PER_SCHEDULED_THREAD_POOL, new PoolThreadFactory("L2JM-S-", Thread.NORM_PRIORITY)); + final int poolCount = Config.INSTANT_THREAD_POOL_COUNT != -1 ? Config.INSTANT_THREAD_POOL_COUNT : Runtime.getRuntime().availableProcessors() * Config.THREADS_PER_INSTANT_THREAD_POOL; + THREAD_POOL_EXECUTOR = new ThreadPoolExecutor(poolCount, poolCount, 1, TimeUnit.MINUTES, new LinkedBlockingQueue<>(), new PoolThreadFactory("L2JM-I-", Thread.NORM_PRIORITY)); getThreadPools().forEach(tp -> { diff --git a/L2J_Mobius_1.0_Ertheia/java/com/l2jmobius/gameserver/GameServer.java b/L2J_Mobius_1.0_Ertheia/java/com/l2jmobius/gameserver/GameServer.java index de6d69e7db..b0ac450a50 100644 --- a/L2J_Mobius_1.0_Ertheia/java/com/l2jmobius/gameserver/GameServer.java +++ b/L2J_Mobius_1.0_Ertheia/java/com/l2jmobius/gameserver/GameServer.java @@ -174,7 +174,7 @@ public class GameServer final long serverLoadStart = System.currentTimeMillis(); printSection("ThreadPool"); - ThreadPool.initThreadPools(new GameThreadPools()); + ThreadPool.init(); printSection("IdFactory"); if (!IdFactory.getInstance().isInitialized()) diff --git a/L2J_Mobius_1.0_Ertheia/java/com/l2jmobius/gameserver/GameThreadPools.java b/L2J_Mobius_1.0_Ertheia/java/com/l2jmobius/gameserver/GameThreadPools.java deleted file mode 100644 index 654b0e2951..0000000000 --- a/L2J_Mobius_1.0_Ertheia/java/com/l2jmobius/gameserver/GameThreadPools.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * This file is part of the L2J Mobius project. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package com.l2jmobius.gameserver; - -import com.l2jmobius.Config; -import com.l2jmobius.commons.concurrent.IThreadPoolInitializer; - -/** - * @author nos - */ -public final class GameThreadPools implements IThreadPoolInitializer -{ - @Override - public int getScheduledThreadPoolSize() - { - return Config.SCHEDULED_THREAD_POOL_COUNT != -1 ? Config.SCHEDULED_THREAD_POOL_COUNT : Runtime.getRuntime().availableProcessors() * Config.THREADS_PER_SCHEDULED_THREAD_POOL; - } - - @Override - public int getThreadPoolSize() - { - return Config.INSTANT_THREAD_POOL_COUNT != -1 ? Config.INSTANT_THREAD_POOL_COUNT : Runtime.getRuntime().availableProcessors() * Config.THREADS_PER_INSTANT_THREAD_POOL; - } -} diff --git a/L2J_Mobius_2.5_Underground/java/com/l2jmobius/commons/concurrent/IThreadPoolInitializer.java b/L2J_Mobius_2.5_Underground/java/com/l2jmobius/commons/concurrent/IThreadPoolInitializer.java deleted file mode 100644 index 43cb09350f..0000000000 --- a/L2J_Mobius_2.5_Underground/java/com/l2jmobius/commons/concurrent/IThreadPoolInitializer.java +++ /dev/null @@ -1,24 +0,0 @@ -/* - * This file is part of the L2J Mobius project. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package com.l2jmobius.commons.concurrent; - -public interface IThreadPoolInitializer -{ - int getScheduledThreadPoolSize(); - - int getThreadPoolSize(); -} diff --git a/L2J_Mobius_2.5_Underground/java/com/l2jmobius/commons/concurrent/ThreadPool.java b/L2J_Mobius_2.5_Underground/java/com/l2jmobius/commons/concurrent/ThreadPool.java index b56ca136e6..6473b38b06 100644 --- a/L2J_Mobius_2.5_Underground/java/com/l2jmobius/commons/concurrent/ThreadPool.java +++ b/L2J_Mobius_2.5_Underground/java/com/l2jmobius/commons/concurrent/ThreadPool.java @@ -29,6 +29,8 @@ import java.util.concurrent.atomic.AtomicInteger; import java.util.logging.Logger; import java.util.stream.Stream; +import com.l2jmobius.Config; + /** * @author _dev_ (savormix) * @author NB4L1 @@ -40,15 +42,16 @@ public final class ThreadPool private static ScheduledThreadPoolExecutor SCHEDULED_THREAD_POOL_EXECUTOR; private static ThreadPoolExecutor THREAD_POOL_EXECUTOR; - public static void initThreadPools(IThreadPoolInitializer initializer) throws Exception + public static void init() throws Exception { if ((SCHEDULED_THREAD_POOL_EXECUTOR != null) || (THREAD_POOL_EXECUTOR != null)) { throw new Exception("The thread pool has been already initialized!"); } - SCHEDULED_THREAD_POOL_EXECUTOR = new ScheduledThreadPoolExecutor(initializer.getScheduledThreadPoolSize(), new PoolThreadFactory("L2JU-SP-", Thread.NORM_PRIORITY)); - THREAD_POOL_EXECUTOR = new ThreadPoolExecutor(initializer.getThreadPoolSize(), initializer.getThreadPoolSize(), 1, TimeUnit.MINUTES, new LinkedBlockingQueue<>(), new PoolThreadFactory("L2JU-IT-", Thread.NORM_PRIORITY)); + SCHEDULED_THREAD_POOL_EXECUTOR = new ScheduledThreadPoolExecutor(Config.SCHEDULED_THREAD_POOL_COUNT != -1 ? Config.SCHEDULED_THREAD_POOL_COUNT : Runtime.getRuntime().availableProcessors() * Config.THREADS_PER_SCHEDULED_THREAD_POOL, new PoolThreadFactory("L2JM-S-", Thread.NORM_PRIORITY)); + final int poolCount = Config.INSTANT_THREAD_POOL_COUNT != -1 ? Config.INSTANT_THREAD_POOL_COUNT : Runtime.getRuntime().availableProcessors() * Config.THREADS_PER_INSTANT_THREAD_POOL; + THREAD_POOL_EXECUTOR = new ThreadPoolExecutor(poolCount, poolCount, 1, TimeUnit.MINUTES, new LinkedBlockingQueue<>(), new PoolThreadFactory("L2JM-I-", Thread.NORM_PRIORITY)); getThreadPools().forEach(tp -> { diff --git a/L2J_Mobius_2.5_Underground/java/com/l2jmobius/gameserver/GameServer.java b/L2J_Mobius_2.5_Underground/java/com/l2jmobius/gameserver/GameServer.java index 2ab5d78d44..1ba2e69658 100644 --- a/L2J_Mobius_2.5_Underground/java/com/l2jmobius/gameserver/GameServer.java +++ b/L2J_Mobius_2.5_Underground/java/com/l2jmobius/gameserver/GameServer.java @@ -178,7 +178,7 @@ public class GameServer final long serverLoadStart = System.currentTimeMillis(); printSection("ThreadPool"); - ThreadPool.initThreadPools(new GameThreadPools()); + ThreadPool.init(); printSection("IdFactory"); if (!IdFactory.getInstance().isInitialized()) diff --git a/L2J_Mobius_2.5_Underground/java/com/l2jmobius/gameserver/GameThreadPools.java b/L2J_Mobius_2.5_Underground/java/com/l2jmobius/gameserver/GameThreadPools.java deleted file mode 100644 index 654b0e2951..0000000000 --- a/L2J_Mobius_2.5_Underground/java/com/l2jmobius/gameserver/GameThreadPools.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * This file is part of the L2J Mobius project. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package com.l2jmobius.gameserver; - -import com.l2jmobius.Config; -import com.l2jmobius.commons.concurrent.IThreadPoolInitializer; - -/** - * @author nos - */ -public final class GameThreadPools implements IThreadPoolInitializer -{ - @Override - public int getScheduledThreadPoolSize() - { - return Config.SCHEDULED_THREAD_POOL_COUNT != -1 ? Config.SCHEDULED_THREAD_POOL_COUNT : Runtime.getRuntime().availableProcessors() * Config.THREADS_PER_SCHEDULED_THREAD_POOL; - } - - @Override - public int getThreadPoolSize() - { - return Config.INSTANT_THREAD_POOL_COUNT != -1 ? Config.INSTANT_THREAD_POOL_COUNT : Runtime.getRuntime().availableProcessors() * Config.THREADS_PER_INSTANT_THREAD_POOL; - } -} diff --git a/L2J_Mobius_3.0_Helios/java/com/l2jmobius/commons/concurrent/IThreadPoolInitializer.java b/L2J_Mobius_3.0_Helios/java/com/l2jmobius/commons/concurrent/IThreadPoolInitializer.java deleted file mode 100644 index 43cb09350f..0000000000 --- a/L2J_Mobius_3.0_Helios/java/com/l2jmobius/commons/concurrent/IThreadPoolInitializer.java +++ /dev/null @@ -1,24 +0,0 @@ -/* - * This file is part of the L2J Mobius project. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package com.l2jmobius.commons.concurrent; - -public interface IThreadPoolInitializer -{ - int getScheduledThreadPoolSize(); - - int getThreadPoolSize(); -} diff --git a/L2J_Mobius_3.0_Helios/java/com/l2jmobius/commons/concurrent/ThreadPool.java b/L2J_Mobius_3.0_Helios/java/com/l2jmobius/commons/concurrent/ThreadPool.java index b56ca136e6..6473b38b06 100644 --- a/L2J_Mobius_3.0_Helios/java/com/l2jmobius/commons/concurrent/ThreadPool.java +++ b/L2J_Mobius_3.0_Helios/java/com/l2jmobius/commons/concurrent/ThreadPool.java @@ -29,6 +29,8 @@ import java.util.concurrent.atomic.AtomicInteger; import java.util.logging.Logger; import java.util.stream.Stream; +import com.l2jmobius.Config; + /** * @author _dev_ (savormix) * @author NB4L1 @@ -40,15 +42,16 @@ public final class ThreadPool private static ScheduledThreadPoolExecutor SCHEDULED_THREAD_POOL_EXECUTOR; private static ThreadPoolExecutor THREAD_POOL_EXECUTOR; - public static void initThreadPools(IThreadPoolInitializer initializer) throws Exception + public static void init() throws Exception { if ((SCHEDULED_THREAD_POOL_EXECUTOR != null) || (THREAD_POOL_EXECUTOR != null)) { throw new Exception("The thread pool has been already initialized!"); } - SCHEDULED_THREAD_POOL_EXECUTOR = new ScheduledThreadPoolExecutor(initializer.getScheduledThreadPoolSize(), new PoolThreadFactory("L2JU-SP-", Thread.NORM_PRIORITY)); - THREAD_POOL_EXECUTOR = new ThreadPoolExecutor(initializer.getThreadPoolSize(), initializer.getThreadPoolSize(), 1, TimeUnit.MINUTES, new LinkedBlockingQueue<>(), new PoolThreadFactory("L2JU-IT-", Thread.NORM_PRIORITY)); + SCHEDULED_THREAD_POOL_EXECUTOR = new ScheduledThreadPoolExecutor(Config.SCHEDULED_THREAD_POOL_COUNT != -1 ? Config.SCHEDULED_THREAD_POOL_COUNT : Runtime.getRuntime().availableProcessors() * Config.THREADS_PER_SCHEDULED_THREAD_POOL, new PoolThreadFactory("L2JM-S-", Thread.NORM_PRIORITY)); + final int poolCount = Config.INSTANT_THREAD_POOL_COUNT != -1 ? Config.INSTANT_THREAD_POOL_COUNT : Runtime.getRuntime().availableProcessors() * Config.THREADS_PER_INSTANT_THREAD_POOL; + THREAD_POOL_EXECUTOR = new ThreadPoolExecutor(poolCount, poolCount, 1, TimeUnit.MINUTES, new LinkedBlockingQueue<>(), new PoolThreadFactory("L2JM-I-", Thread.NORM_PRIORITY)); getThreadPools().forEach(tp -> { diff --git a/L2J_Mobius_3.0_Helios/java/com/l2jmobius/gameserver/GameServer.java b/L2J_Mobius_3.0_Helios/java/com/l2jmobius/gameserver/GameServer.java index dce6e566aa..aca0927afe 100644 --- a/L2J_Mobius_3.0_Helios/java/com/l2jmobius/gameserver/GameServer.java +++ b/L2J_Mobius_3.0_Helios/java/com/l2jmobius/gameserver/GameServer.java @@ -178,7 +178,7 @@ public class GameServer final long serverLoadStart = System.currentTimeMillis(); printSection("ThreadPool"); - ThreadPool.initThreadPools(new GameThreadPools()); + ThreadPool.init(); printSection("IdFactory"); if (!IdFactory.getInstance().isInitialized()) diff --git a/L2J_Mobius_3.0_Helios/java/com/l2jmobius/gameserver/GameThreadPools.java b/L2J_Mobius_3.0_Helios/java/com/l2jmobius/gameserver/GameThreadPools.java deleted file mode 100644 index 654b0e2951..0000000000 --- a/L2J_Mobius_3.0_Helios/java/com/l2jmobius/gameserver/GameThreadPools.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * This file is part of the L2J Mobius project. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package com.l2jmobius.gameserver; - -import com.l2jmobius.Config; -import com.l2jmobius.commons.concurrent.IThreadPoolInitializer; - -/** - * @author nos - */ -public final class GameThreadPools implements IThreadPoolInitializer -{ - @Override - public int getScheduledThreadPoolSize() - { - return Config.SCHEDULED_THREAD_POOL_COUNT != -1 ? Config.SCHEDULED_THREAD_POOL_COUNT : Runtime.getRuntime().availableProcessors() * Config.THREADS_PER_SCHEDULED_THREAD_POOL; - } - - @Override - public int getThreadPoolSize() - { - return Config.INSTANT_THREAD_POOL_COUNT != -1 ? Config.INSTANT_THREAD_POOL_COUNT : Runtime.getRuntime().availableProcessors() * Config.THREADS_PER_INSTANT_THREAD_POOL; - } -} diff --git a/L2J_Mobius_4.0_GrandCrusade/java/com/l2jmobius/commons/concurrent/IThreadPoolInitializer.java b/L2J_Mobius_4.0_GrandCrusade/java/com/l2jmobius/commons/concurrent/IThreadPoolInitializer.java deleted file mode 100644 index 43cb09350f..0000000000 --- a/L2J_Mobius_4.0_GrandCrusade/java/com/l2jmobius/commons/concurrent/IThreadPoolInitializer.java +++ /dev/null @@ -1,24 +0,0 @@ -/* - * This file is part of the L2J Mobius project. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package com.l2jmobius.commons.concurrent; - -public interface IThreadPoolInitializer -{ - int getScheduledThreadPoolSize(); - - int getThreadPoolSize(); -} diff --git a/L2J_Mobius_4.0_GrandCrusade/java/com/l2jmobius/commons/concurrent/ThreadPool.java b/L2J_Mobius_4.0_GrandCrusade/java/com/l2jmobius/commons/concurrent/ThreadPool.java index b56ca136e6..6473b38b06 100644 --- a/L2J_Mobius_4.0_GrandCrusade/java/com/l2jmobius/commons/concurrent/ThreadPool.java +++ b/L2J_Mobius_4.0_GrandCrusade/java/com/l2jmobius/commons/concurrent/ThreadPool.java @@ -29,6 +29,8 @@ import java.util.concurrent.atomic.AtomicInteger; import java.util.logging.Logger; import java.util.stream.Stream; +import com.l2jmobius.Config; + /** * @author _dev_ (savormix) * @author NB4L1 @@ -40,15 +42,16 @@ public final class ThreadPool private static ScheduledThreadPoolExecutor SCHEDULED_THREAD_POOL_EXECUTOR; private static ThreadPoolExecutor THREAD_POOL_EXECUTOR; - public static void initThreadPools(IThreadPoolInitializer initializer) throws Exception + public static void init() throws Exception { if ((SCHEDULED_THREAD_POOL_EXECUTOR != null) || (THREAD_POOL_EXECUTOR != null)) { throw new Exception("The thread pool has been already initialized!"); } - SCHEDULED_THREAD_POOL_EXECUTOR = new ScheduledThreadPoolExecutor(initializer.getScheduledThreadPoolSize(), new PoolThreadFactory("L2JU-SP-", Thread.NORM_PRIORITY)); - THREAD_POOL_EXECUTOR = new ThreadPoolExecutor(initializer.getThreadPoolSize(), initializer.getThreadPoolSize(), 1, TimeUnit.MINUTES, new LinkedBlockingQueue<>(), new PoolThreadFactory("L2JU-IT-", Thread.NORM_PRIORITY)); + SCHEDULED_THREAD_POOL_EXECUTOR = new ScheduledThreadPoolExecutor(Config.SCHEDULED_THREAD_POOL_COUNT != -1 ? Config.SCHEDULED_THREAD_POOL_COUNT : Runtime.getRuntime().availableProcessors() * Config.THREADS_PER_SCHEDULED_THREAD_POOL, new PoolThreadFactory("L2JM-S-", Thread.NORM_PRIORITY)); + final int poolCount = Config.INSTANT_THREAD_POOL_COUNT != -1 ? Config.INSTANT_THREAD_POOL_COUNT : Runtime.getRuntime().availableProcessors() * Config.THREADS_PER_INSTANT_THREAD_POOL; + THREAD_POOL_EXECUTOR = new ThreadPoolExecutor(poolCount, poolCount, 1, TimeUnit.MINUTES, new LinkedBlockingQueue<>(), new PoolThreadFactory("L2JM-I-", Thread.NORM_PRIORITY)); getThreadPools().forEach(tp -> { diff --git a/L2J_Mobius_4.0_GrandCrusade/java/com/l2jmobius/gameserver/GameServer.java b/L2J_Mobius_4.0_GrandCrusade/java/com/l2jmobius/gameserver/GameServer.java index b714cdf228..2e11e61e48 100644 --- a/L2J_Mobius_4.0_GrandCrusade/java/com/l2jmobius/gameserver/GameServer.java +++ b/L2J_Mobius_4.0_GrandCrusade/java/com/l2jmobius/gameserver/GameServer.java @@ -178,7 +178,7 @@ public class GameServer final long serverLoadStart = System.currentTimeMillis(); printSection("ThreadPool"); - ThreadPool.initThreadPools(new GameThreadPools()); + ThreadPool.init(); printSection("IdFactory"); if (!IdFactory.getInstance().isInitialized()) diff --git a/L2J_Mobius_4.0_GrandCrusade/java/com/l2jmobius/gameserver/GameThreadPools.java b/L2J_Mobius_4.0_GrandCrusade/java/com/l2jmobius/gameserver/GameThreadPools.java deleted file mode 100644 index 654b0e2951..0000000000 --- a/L2J_Mobius_4.0_GrandCrusade/java/com/l2jmobius/gameserver/GameThreadPools.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * This file is part of the L2J Mobius project. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package com.l2jmobius.gameserver; - -import com.l2jmobius.Config; -import com.l2jmobius.commons.concurrent.IThreadPoolInitializer; - -/** - * @author nos - */ -public final class GameThreadPools implements IThreadPoolInitializer -{ - @Override - public int getScheduledThreadPoolSize() - { - return Config.SCHEDULED_THREAD_POOL_COUNT != -1 ? Config.SCHEDULED_THREAD_POOL_COUNT : Runtime.getRuntime().availableProcessors() * Config.THREADS_PER_SCHEDULED_THREAD_POOL; - } - - @Override - public int getThreadPoolSize() - { - return Config.INSTANT_THREAD_POOL_COUNT != -1 ? Config.INSTANT_THREAD_POOL_COUNT : Runtime.getRuntime().availableProcessors() * Config.THREADS_PER_INSTANT_THREAD_POOL; - } -} diff --git a/L2J_Mobius_C6_Interlude/java/com/l2jmobius/commons/concurrent/IThreadPoolInitializer.java b/L2J_Mobius_C6_Interlude/java/com/l2jmobius/commons/concurrent/IThreadPoolInitializer.java deleted file mode 100644 index 43cb09350f..0000000000 --- a/L2J_Mobius_C6_Interlude/java/com/l2jmobius/commons/concurrent/IThreadPoolInitializer.java +++ /dev/null @@ -1,24 +0,0 @@ -/* - * This file is part of the L2J Mobius project. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package com.l2jmobius.commons.concurrent; - -public interface IThreadPoolInitializer -{ - int getScheduledThreadPoolSize(); - - int getThreadPoolSize(); -} diff --git a/L2J_Mobius_C6_Interlude/java/com/l2jmobius/commons/concurrent/ThreadPool.java b/L2J_Mobius_C6_Interlude/java/com/l2jmobius/commons/concurrent/ThreadPool.java index b56ca136e6..6473b38b06 100644 --- a/L2J_Mobius_C6_Interlude/java/com/l2jmobius/commons/concurrent/ThreadPool.java +++ b/L2J_Mobius_C6_Interlude/java/com/l2jmobius/commons/concurrent/ThreadPool.java @@ -29,6 +29,8 @@ import java.util.concurrent.atomic.AtomicInteger; import java.util.logging.Logger; import java.util.stream.Stream; +import com.l2jmobius.Config; + /** * @author _dev_ (savormix) * @author NB4L1 @@ -40,15 +42,16 @@ public final class ThreadPool private static ScheduledThreadPoolExecutor SCHEDULED_THREAD_POOL_EXECUTOR; private static ThreadPoolExecutor THREAD_POOL_EXECUTOR; - public static void initThreadPools(IThreadPoolInitializer initializer) throws Exception + public static void init() throws Exception { if ((SCHEDULED_THREAD_POOL_EXECUTOR != null) || (THREAD_POOL_EXECUTOR != null)) { throw new Exception("The thread pool has been already initialized!"); } - SCHEDULED_THREAD_POOL_EXECUTOR = new ScheduledThreadPoolExecutor(initializer.getScheduledThreadPoolSize(), new PoolThreadFactory("L2JU-SP-", Thread.NORM_PRIORITY)); - THREAD_POOL_EXECUTOR = new ThreadPoolExecutor(initializer.getThreadPoolSize(), initializer.getThreadPoolSize(), 1, TimeUnit.MINUTES, new LinkedBlockingQueue<>(), new PoolThreadFactory("L2JU-IT-", Thread.NORM_PRIORITY)); + SCHEDULED_THREAD_POOL_EXECUTOR = new ScheduledThreadPoolExecutor(Config.SCHEDULED_THREAD_POOL_COUNT != -1 ? Config.SCHEDULED_THREAD_POOL_COUNT : Runtime.getRuntime().availableProcessors() * Config.THREADS_PER_SCHEDULED_THREAD_POOL, new PoolThreadFactory("L2JM-S-", Thread.NORM_PRIORITY)); + final int poolCount = Config.INSTANT_THREAD_POOL_COUNT != -1 ? Config.INSTANT_THREAD_POOL_COUNT : Runtime.getRuntime().availableProcessors() * Config.THREADS_PER_INSTANT_THREAD_POOL; + THREAD_POOL_EXECUTOR = new ThreadPoolExecutor(poolCount, poolCount, 1, TimeUnit.MINUTES, new LinkedBlockingQueue<>(), new PoolThreadFactory("L2JM-I-", Thread.NORM_PRIORITY)); getThreadPools().forEach(tp -> { diff --git a/L2J_Mobius_C6_Interlude/java/com/l2jmobius/gameserver/GameServer.java b/L2J_Mobius_C6_Interlude/java/com/l2jmobius/gameserver/GameServer.java index f0f9439f9b..a56d891d52 100644 --- a/L2J_Mobius_C6_Interlude/java/com/l2jmobius/gameserver/GameServer.java +++ b/L2J_Mobius_C6_Interlude/java/com/l2jmobius/gameserver/GameServer.java @@ -181,7 +181,7 @@ public class GameServer DatabaseFactory.getInstance(); Util.printSection("ThreadPool"); - ThreadPool.initThreadPools(new GameThreadPools()); + ThreadPool.init(); if (Config.DEADLOCKCHECK_INTIAL_TIME > 0) { ThreadPool.scheduleAtFixedRate(DeadlockDetector.getInstance(), Config.DEADLOCKCHECK_INTIAL_TIME, Config.DEADLOCKCHECK_DELAY_TIME); diff --git a/L2J_Mobius_C6_Interlude/java/com/l2jmobius/gameserver/GameThreadPools.java b/L2J_Mobius_C6_Interlude/java/com/l2jmobius/gameserver/GameThreadPools.java deleted file mode 100644 index 654b0e2951..0000000000 --- a/L2J_Mobius_C6_Interlude/java/com/l2jmobius/gameserver/GameThreadPools.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * This file is part of the L2J Mobius project. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package com.l2jmobius.gameserver; - -import com.l2jmobius.Config; -import com.l2jmobius.commons.concurrent.IThreadPoolInitializer; - -/** - * @author nos - */ -public final class GameThreadPools implements IThreadPoolInitializer -{ - @Override - public int getScheduledThreadPoolSize() - { - return Config.SCHEDULED_THREAD_POOL_COUNT != -1 ? Config.SCHEDULED_THREAD_POOL_COUNT : Runtime.getRuntime().availableProcessors() * Config.THREADS_PER_SCHEDULED_THREAD_POOL; - } - - @Override - public int getThreadPoolSize() - { - return Config.INSTANT_THREAD_POOL_COUNT != -1 ? Config.INSTANT_THREAD_POOL_COUNT : Runtime.getRuntime().availableProcessors() * Config.THREADS_PER_INSTANT_THREAD_POOL; - } -} diff --git a/L2J_Mobius_CT_2.6_HighFive/java/com/l2jmobius/commons/concurrent/IThreadPoolInitializer.java b/L2J_Mobius_CT_2.6_HighFive/java/com/l2jmobius/commons/concurrent/IThreadPoolInitializer.java deleted file mode 100644 index 43cb09350f..0000000000 --- a/L2J_Mobius_CT_2.6_HighFive/java/com/l2jmobius/commons/concurrent/IThreadPoolInitializer.java +++ /dev/null @@ -1,24 +0,0 @@ -/* - * This file is part of the L2J Mobius project. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package com.l2jmobius.commons.concurrent; - -public interface IThreadPoolInitializer -{ - int getScheduledThreadPoolSize(); - - int getThreadPoolSize(); -} diff --git a/L2J_Mobius_CT_2.6_HighFive/java/com/l2jmobius/commons/concurrent/ThreadPool.java b/L2J_Mobius_CT_2.6_HighFive/java/com/l2jmobius/commons/concurrent/ThreadPool.java index af159a4826..f48edf407f 100644 --- a/L2J_Mobius_CT_2.6_HighFive/java/com/l2jmobius/commons/concurrent/ThreadPool.java +++ b/L2J_Mobius_CT_2.6_HighFive/java/com/l2jmobius/commons/concurrent/ThreadPool.java @@ -29,6 +29,8 @@ import java.util.concurrent.atomic.AtomicInteger; import java.util.logging.Logger; import java.util.stream.Stream; +import com.l2jmobius.Config; + /** * @author _dev_ (savormix) * @author NB4L1 @@ -40,15 +42,16 @@ public final class ThreadPool private static ScheduledThreadPoolExecutor SCHEDULED_THREAD_POOL_EXECUTOR; private static ThreadPoolExecutor THREAD_POOL_EXECUTOR; - public static void initThreadPools(IThreadPoolInitializer initializer) throws Exception + public static void init() throws Exception { if ((SCHEDULED_THREAD_POOL_EXECUTOR != null) || (THREAD_POOL_EXECUTOR != null)) { throw new Exception("The thread pool has been already initialized!"); } - SCHEDULED_THREAD_POOL_EXECUTOR = new ScheduledThreadPoolExecutor(initializer.getScheduledThreadPoolSize(), new PoolThreadFactory("L2JU-SP-", Thread.NORM_PRIORITY)); - THREAD_POOL_EXECUTOR = new ThreadPoolExecutor(initializer.getThreadPoolSize(), initializer.getThreadPoolSize(), 1, TimeUnit.MINUTES, new LinkedBlockingQueue<>(), new PoolThreadFactory("L2JU-IT-", Thread.NORM_PRIORITY)); + SCHEDULED_THREAD_POOL_EXECUTOR = new ScheduledThreadPoolExecutor(Config.SCHEDULED_THREAD_POOL_COUNT != -1 ? Config.SCHEDULED_THREAD_POOL_COUNT : Runtime.getRuntime().availableProcessors() * Config.THREADS_PER_SCHEDULED_THREAD_POOL, new PoolThreadFactory("L2JM-S-", Thread.NORM_PRIORITY)); + final int poolCount = Config.INSTANT_THREAD_POOL_COUNT != -1 ? Config.INSTANT_THREAD_POOL_COUNT : Runtime.getRuntime().availableProcessors() * Config.THREADS_PER_INSTANT_THREAD_POOL; + THREAD_POOL_EXECUTOR = new ThreadPoolExecutor(poolCount, poolCount, 1, TimeUnit.MINUTES, new LinkedBlockingQueue<>(), new PoolThreadFactory("L2JM-I-", Thread.NORM_PRIORITY)); getThreadPools().forEach(tp -> { diff --git a/L2J_Mobius_CT_2.6_HighFive/java/com/l2jmobius/gameserver/GameServer.java b/L2J_Mobius_CT_2.6_HighFive/java/com/l2jmobius/gameserver/GameServer.java index 20fc229192..acfd9d0d85 100644 --- a/L2J_Mobius_CT_2.6_HighFive/java/com/l2jmobius/gameserver/GameServer.java +++ b/L2J_Mobius_CT_2.6_HighFive/java/com/l2jmobius/gameserver/GameServer.java @@ -162,7 +162,7 @@ public final class GameServer final long serverLoadStart = System.currentTimeMillis(); printSection("ThreadPool"); - ThreadPool.initThreadPools(new GameThreadPools()); + ThreadPool.init(); printSection("IdFactory"); if (!IdFactory.getInstance().isInitialized()) diff --git a/L2J_Mobius_CT_2.6_HighFive/java/com/l2jmobius/gameserver/GameThreadPools.java b/L2J_Mobius_CT_2.6_HighFive/java/com/l2jmobius/gameserver/GameThreadPools.java deleted file mode 100644 index 654b0e2951..0000000000 --- a/L2J_Mobius_CT_2.6_HighFive/java/com/l2jmobius/gameserver/GameThreadPools.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * This file is part of the L2J Mobius project. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package com.l2jmobius.gameserver; - -import com.l2jmobius.Config; -import com.l2jmobius.commons.concurrent.IThreadPoolInitializer; - -/** - * @author nos - */ -public final class GameThreadPools implements IThreadPoolInitializer -{ - @Override - public int getScheduledThreadPoolSize() - { - return Config.SCHEDULED_THREAD_POOL_COUNT != -1 ? Config.SCHEDULED_THREAD_POOL_COUNT : Runtime.getRuntime().availableProcessors() * Config.THREADS_PER_SCHEDULED_THREAD_POOL; - } - - @Override - public int getThreadPoolSize() - { - return Config.INSTANT_THREAD_POOL_COUNT != -1 ? Config.INSTANT_THREAD_POOL_COUNT : Runtime.getRuntime().availableProcessors() * Config.THREADS_PER_INSTANT_THREAD_POOL; - } -} diff --git a/L2J_Mobius_Classic_2.0_Saviors/java/com/l2jmobius/commons/concurrent/IThreadPoolInitializer.java b/L2J_Mobius_Classic_2.0_Saviors/java/com/l2jmobius/commons/concurrent/IThreadPoolInitializer.java deleted file mode 100644 index 43cb09350f..0000000000 --- a/L2J_Mobius_Classic_2.0_Saviors/java/com/l2jmobius/commons/concurrent/IThreadPoolInitializer.java +++ /dev/null @@ -1,24 +0,0 @@ -/* - * This file is part of the L2J Mobius project. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package com.l2jmobius.commons.concurrent; - -public interface IThreadPoolInitializer -{ - int getScheduledThreadPoolSize(); - - int getThreadPoolSize(); -} diff --git a/L2J_Mobius_Classic_2.0_Saviors/java/com/l2jmobius/commons/concurrent/ThreadPool.java b/L2J_Mobius_Classic_2.0_Saviors/java/com/l2jmobius/commons/concurrent/ThreadPool.java index b56ca136e6..6473b38b06 100644 --- a/L2J_Mobius_Classic_2.0_Saviors/java/com/l2jmobius/commons/concurrent/ThreadPool.java +++ b/L2J_Mobius_Classic_2.0_Saviors/java/com/l2jmobius/commons/concurrent/ThreadPool.java @@ -29,6 +29,8 @@ import java.util.concurrent.atomic.AtomicInteger; import java.util.logging.Logger; import java.util.stream.Stream; +import com.l2jmobius.Config; + /** * @author _dev_ (savormix) * @author NB4L1 @@ -40,15 +42,16 @@ public final class ThreadPool private static ScheduledThreadPoolExecutor SCHEDULED_THREAD_POOL_EXECUTOR; private static ThreadPoolExecutor THREAD_POOL_EXECUTOR; - public static void initThreadPools(IThreadPoolInitializer initializer) throws Exception + public static void init() throws Exception { if ((SCHEDULED_THREAD_POOL_EXECUTOR != null) || (THREAD_POOL_EXECUTOR != null)) { throw new Exception("The thread pool has been already initialized!"); } - SCHEDULED_THREAD_POOL_EXECUTOR = new ScheduledThreadPoolExecutor(initializer.getScheduledThreadPoolSize(), new PoolThreadFactory("L2JU-SP-", Thread.NORM_PRIORITY)); - THREAD_POOL_EXECUTOR = new ThreadPoolExecutor(initializer.getThreadPoolSize(), initializer.getThreadPoolSize(), 1, TimeUnit.MINUTES, new LinkedBlockingQueue<>(), new PoolThreadFactory("L2JU-IT-", Thread.NORM_PRIORITY)); + SCHEDULED_THREAD_POOL_EXECUTOR = new ScheduledThreadPoolExecutor(Config.SCHEDULED_THREAD_POOL_COUNT != -1 ? Config.SCHEDULED_THREAD_POOL_COUNT : Runtime.getRuntime().availableProcessors() * Config.THREADS_PER_SCHEDULED_THREAD_POOL, new PoolThreadFactory("L2JM-S-", Thread.NORM_PRIORITY)); + final int poolCount = Config.INSTANT_THREAD_POOL_COUNT != -1 ? Config.INSTANT_THREAD_POOL_COUNT : Runtime.getRuntime().availableProcessors() * Config.THREADS_PER_INSTANT_THREAD_POOL; + THREAD_POOL_EXECUTOR = new ThreadPoolExecutor(poolCount, poolCount, 1, TimeUnit.MINUTES, new LinkedBlockingQueue<>(), new PoolThreadFactory("L2JM-I-", Thread.NORM_PRIORITY)); getThreadPools().forEach(tp -> { diff --git a/L2J_Mobius_Classic_2.0_Saviors/java/com/l2jmobius/gameserver/GameServer.java b/L2J_Mobius_Classic_2.0_Saviors/java/com/l2jmobius/gameserver/GameServer.java index a96d0300bc..2b32c16a96 100644 --- a/L2J_Mobius_Classic_2.0_Saviors/java/com/l2jmobius/gameserver/GameServer.java +++ b/L2J_Mobius_Classic_2.0_Saviors/java/com/l2jmobius/gameserver/GameServer.java @@ -174,7 +174,7 @@ public class GameServer final long serverLoadStart = System.currentTimeMillis(); printSection("ThreadPool"); - ThreadPool.initThreadPools(new GameThreadPools()); + ThreadPool.init(); printSection("IdFactory"); if (!IdFactory.getInstance().isInitialized()) diff --git a/L2J_Mobius_Classic_2.0_Saviors/java/com/l2jmobius/gameserver/GameThreadPools.java b/L2J_Mobius_Classic_2.0_Saviors/java/com/l2jmobius/gameserver/GameThreadPools.java deleted file mode 100644 index 654b0e2951..0000000000 --- a/L2J_Mobius_Classic_2.0_Saviors/java/com/l2jmobius/gameserver/GameThreadPools.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * This file is part of the L2J Mobius project. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package com.l2jmobius.gameserver; - -import com.l2jmobius.Config; -import com.l2jmobius.commons.concurrent.IThreadPoolInitializer; - -/** - * @author nos - */ -public final class GameThreadPools implements IThreadPoolInitializer -{ - @Override - public int getScheduledThreadPoolSize() - { - return Config.SCHEDULED_THREAD_POOL_COUNT != -1 ? Config.SCHEDULED_THREAD_POOL_COUNT : Runtime.getRuntime().availableProcessors() * Config.THREADS_PER_SCHEDULED_THREAD_POOL; - } - - @Override - public int getThreadPoolSize() - { - return Config.INSTANT_THREAD_POOL_COUNT != -1 ? Config.INSTANT_THREAD_POOL_COUNT : Runtime.getRuntime().availableProcessors() * Config.THREADS_PER_INSTANT_THREAD_POOL; - } -} diff --git a/L2J_Mobius_Classic_2.0_Zaken/java/com/l2jmobius/commons/concurrent/IThreadPoolInitializer.java b/L2J_Mobius_Classic_2.0_Zaken/java/com/l2jmobius/commons/concurrent/IThreadPoolInitializer.java deleted file mode 100644 index 4d12369547..0000000000 --- a/L2J_Mobius_Classic_2.0_Zaken/java/com/l2jmobius/commons/concurrent/IThreadPoolInitializer.java +++ /dev/null @@ -1,24 +0,0 @@ -/* - * This file is part of the L2J Mobius project. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package com.l2jmobius.commons.concurrent; - -public interface IThreadPoolInitializer -{ - int getScheduledThreadPoolSize(); - - int getThreadPoolSize(); -} diff --git a/L2J_Mobius_Classic_2.0_Zaken/java/com/l2jmobius/commons/concurrent/ThreadPool.java b/L2J_Mobius_Classic_2.0_Zaken/java/com/l2jmobius/commons/concurrent/ThreadPool.java index af159a4826..f48edf407f 100644 --- a/L2J_Mobius_Classic_2.0_Zaken/java/com/l2jmobius/commons/concurrent/ThreadPool.java +++ b/L2J_Mobius_Classic_2.0_Zaken/java/com/l2jmobius/commons/concurrent/ThreadPool.java @@ -29,6 +29,8 @@ import java.util.concurrent.atomic.AtomicInteger; import java.util.logging.Logger; import java.util.stream.Stream; +import com.l2jmobius.Config; + /** * @author _dev_ (savormix) * @author NB4L1 @@ -40,15 +42,16 @@ public final class ThreadPool private static ScheduledThreadPoolExecutor SCHEDULED_THREAD_POOL_EXECUTOR; private static ThreadPoolExecutor THREAD_POOL_EXECUTOR; - public static void initThreadPools(IThreadPoolInitializer initializer) throws Exception + public static void init() throws Exception { if ((SCHEDULED_THREAD_POOL_EXECUTOR != null) || (THREAD_POOL_EXECUTOR != null)) { throw new Exception("The thread pool has been already initialized!"); } - SCHEDULED_THREAD_POOL_EXECUTOR = new ScheduledThreadPoolExecutor(initializer.getScheduledThreadPoolSize(), new PoolThreadFactory("L2JU-SP-", Thread.NORM_PRIORITY)); - THREAD_POOL_EXECUTOR = new ThreadPoolExecutor(initializer.getThreadPoolSize(), initializer.getThreadPoolSize(), 1, TimeUnit.MINUTES, new LinkedBlockingQueue<>(), new PoolThreadFactory("L2JU-IT-", Thread.NORM_PRIORITY)); + SCHEDULED_THREAD_POOL_EXECUTOR = new ScheduledThreadPoolExecutor(Config.SCHEDULED_THREAD_POOL_COUNT != -1 ? Config.SCHEDULED_THREAD_POOL_COUNT : Runtime.getRuntime().availableProcessors() * Config.THREADS_PER_SCHEDULED_THREAD_POOL, new PoolThreadFactory("L2JM-S-", Thread.NORM_PRIORITY)); + final int poolCount = Config.INSTANT_THREAD_POOL_COUNT != -1 ? Config.INSTANT_THREAD_POOL_COUNT : Runtime.getRuntime().availableProcessors() * Config.THREADS_PER_INSTANT_THREAD_POOL; + THREAD_POOL_EXECUTOR = new ThreadPoolExecutor(poolCount, poolCount, 1, TimeUnit.MINUTES, new LinkedBlockingQueue<>(), new PoolThreadFactory("L2JM-I-", Thread.NORM_PRIORITY)); getThreadPools().forEach(tp -> { diff --git a/L2J_Mobius_Classic_2.0_Zaken/java/com/l2jmobius/gameserver/GameServer.java b/L2J_Mobius_Classic_2.0_Zaken/java/com/l2jmobius/gameserver/GameServer.java index a96d0300bc..2b32c16a96 100644 --- a/L2J_Mobius_Classic_2.0_Zaken/java/com/l2jmobius/gameserver/GameServer.java +++ b/L2J_Mobius_Classic_2.0_Zaken/java/com/l2jmobius/gameserver/GameServer.java @@ -174,7 +174,7 @@ public class GameServer final long serverLoadStart = System.currentTimeMillis(); printSection("ThreadPool"); - ThreadPool.initThreadPools(new GameThreadPools()); + ThreadPool.init(); printSection("IdFactory"); if (!IdFactory.getInstance().isInitialized()) diff --git a/L2J_Mobius_Classic_2.0_Zaken/java/com/l2jmobius/gameserver/GameThreadPools.java b/L2J_Mobius_Classic_2.0_Zaken/java/com/l2jmobius/gameserver/GameThreadPools.java deleted file mode 100644 index 91a2cf0e65..0000000000 --- a/L2J_Mobius_Classic_2.0_Zaken/java/com/l2jmobius/gameserver/GameThreadPools.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * This file is part of the L2J Mobius project. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package com.l2jmobius.gameserver; - -import com.l2jmobius.Config; -import com.l2jmobius.commons.concurrent.IThreadPoolInitializer; - -/** - * @author nos - */ -public final class GameThreadPools implements IThreadPoolInitializer -{ - @Override - public int getScheduledThreadPoolSize() - { - return Config.SCHEDULED_THREAD_POOL_COUNT != -1 ? Config.SCHEDULED_THREAD_POOL_COUNT : Runtime.getRuntime().availableProcessors() * Config.THREADS_PER_SCHEDULED_THREAD_POOL; - } - - @Override - public int getThreadPoolSize() - { - return Config.INSTANT_THREAD_POOL_COUNT != -1 ? Config.INSTANT_THREAD_POOL_COUNT : Runtime.getRuntime().availableProcessors() * Config.THREADS_PER_INSTANT_THREAD_POOL; - } -}