Index: C:/Documents and Settings/-Wooden-/workspace/L2_GameServer_Select/java/net/sf/l2j/gameserver/ClientScheduler.java =================================================================== --- C:/Documents and Settings/-Wooden-/workspace/L2_GameServer_Select/java/net/sf/l2j/gameserver/ClientScheduler.java (revision 1665) +++ C:/Documents and Settings/-Wooden-/workspace/L2_GameServer_Select/java/net/sf/l2j/gameserver/ClientScheduler.java (working copy) @@ -25,6 +25,7 @@ import java.util.concurrent.ScheduledThreadPoolExecutor; import java.util.concurrent.ThreadFactory; import java.util.concurrent.TimeUnit; +import java.util.concurrent.atomic.AtomicBoolean; import java.util.logging.Level; import java.util.logging.Logger; @@ -49,15 +50,18 @@ public static final int PRIORITY_HIGH = 2; public static final int PRIORITY_MEDIUM = 1; public static final int PRIORITY_LOW = 0; + private static final ClientScheduler _instance = new ClientScheduler(); private final ScheduledThreadPoolExecutor _executorHighPriority; private final ScheduledThreadPoolExecutor _executorMedPriority; private final ScheduledThreadPoolExecutor _executorLowPriority; + private final ScheduledThreadPoolExecutor _executorLowPriority2; + private AtomicBoolean firstLowPool = new AtomicBoolean(true); - /** + /** * Constructor of ClientScheduler.

*/ public static final ClientScheduler getInstance() @@ -76,6 +80,7 @@ _executorHighPriority = new ScheduledThreadPoolExecutor(Config.THREAD_P_HIGH, new ThrFactory(1, "PoolHIGH")); _executorMedPriority = new ScheduledThreadPoolExecutor(Config.THREAD_P_MED, new ThrFactory(0, "PoolMED")); _executorLowPriority = new ScheduledThreadPoolExecutor(Config.THREAD_P_LOW, new ThrFactory(-1, "PoolLOW")); + _executorLowPriority2 = new ScheduledThreadPoolExecutor(Config.THREAD_P_LOW, new ThrFactory(-1, "PoolLOW-2")); } /** @@ -86,14 +91,17 @@ try { _executorHighPriority.shutdown(); } catch (Throwable t) { _log.log(Level.WARNING, "", t); } try { _executorMedPriority.shutdown(); } catch (Throwable t) { _log.log(Level.WARNING, "", t); } try { _executorLowPriority.shutdown(); } catch (Throwable t) { _log.log(Level.WARNING, "", t); } + try { _executorLowPriority2.shutdown(); } catch (Throwable t) { _log.log(Level.WARNING, "", t); } try { _executorHighPriority.awaitTermination(1000, TimeUnit.MILLISECONDS); } catch (Throwable t) { _log.log(Level.WARNING, "", t); } try { _executorMedPriority.awaitTermination(1000, TimeUnit.MILLISECONDS); } catch (Throwable t) { _log.log(Level.WARNING, "", t); } - try { _executorLowPriority.awaitTermination(1000, TimeUnit.MILLISECONDS); } catch (Throwable t) { _log.log(Level.WARNING, "", t); } + try { _executorLowPriority.awaitTermination(1000, TimeUnit.MILLISECONDS); } catch (Throwable t) { _log.log(Level.WARNING, "", t); } + try { _executorLowPriority2.awaitTermination(1000, TimeUnit.MILLISECONDS); } catch (Throwable t) { _log.log(Level.WARNING, "", t); } _executorHighPriority.shutdownNow(); - _executorHighPriority.shutdownNow(); - _executorHighPriority.shutdownNow(); + _executorMedPriority.shutdownNow(); + _executorLowPriority.shutdownNow(); + _executorLowPriority2.shutdownNow(); } @@ -122,7 +130,15 @@ return; case PR_LOW: default: - _instance._executorLowPriority.execute(pkt); + if(_instance.firstLowPool.get()) + { + _instance._executorLowPriority.execute(pkt); + } + else + { + _instance._executorLowPriority2.execute(pkt); + } + _instance.firstLowPool.set(!_instance.firstLowPool.get()); return; } } @@ -211,8 +227,18 @@ { try { - if (delay < 0) delay = 0; - return _executorLowPriority.scheduleAtFixedRate(r, initial, delay, TimeUnit.MILLISECONDS); + ScheduledFuture sf = null; + if (delay < 0) delay = 0; + if(_instance.firstLowPool.get()) + { + sf = _executorLowPriority.scheduleAtFixedRate(r, initial, delay, TimeUnit.MILLISECONDS); + } + else + { + sf= _executorLowPriority2.scheduleAtFixedRate(r, initial, delay, TimeUnit.MILLISECONDS); + } + _instance.firstLowPool.set(!_instance.firstLowPool.get()); + return sf; } catch (RejectedExecutionException e) { return null; /* shutdown, ignore */ } } @@ -284,8 +310,18 @@ { try { - if (delay < 0) delay = 0; - return _executorLowPriority.schedule(r, delay, TimeUnit.MILLISECONDS); + ScheduledFuture sf = null; + if (delay < 0) delay = 0; + if(_instance.firstLowPool.get()) + { + sf = _executorLowPriority.schedule(r, delay, TimeUnit.MILLISECONDS); + } + else + { + sf= _executorLowPriority2.schedule(r, delay, TimeUnit.MILLISECONDS); + } + _instance.firstLowPool.set(!_instance.firstLowPool.get()); + return sf; } catch (RejectedExecutionException e) { return null; /* shutdown, ignore */ } } @@ -331,14 +367,22 @@ "LargestPoolSize: "+_executorMedPriority.getLargestPoolSize(), "PoolSize: "+_executorMedPriority.getPoolSize(), "ScheduledTasks: "+_executorMedPriority.getTaskCount(), - "LOW", + "LOW1", "ActiveThreads: "+_executorLowPriority.getActiveCount(), "CompletedTasks: "+_executorLowPriority.getCompletedTaskCount(), "getCorePoolSize: "+_executorLowPriority.getCorePoolSize(), "MaximumPoolSize: "+_executorLowPriority.getMaximumPoolSize(), "LargestPoolSize: "+_executorLowPriority.getLargestPoolSize(), "PoolSize: "+_executorLowPriority.getPoolSize(), - "ScheduledTasks: "+_executorLowPriority.getTaskCount() + "ScheduledTasks: "+_executorLowPriority.getTaskCount(), + "LOW2", + "ActiveThreads: "+_executorLowPriority2.getActiveCount(), + "CompletedTasks: "+_executorLowPriority2.getCompletedTaskCount(), + "getCorePoolSize: "+_executorLowPriority2.getCorePoolSize(), + "MaximumPoolSize: "+_executorLowPriority2.getMaximumPoolSize(), + "LargestPoolSize: "+_executorLowPriority2.getLargestPoolSize(), + "PoolSize: "+_executorLowPriority2.getPoolSize(), + "ScheduledTasks: "+_executorLowPriority2.getTaskCount() }; }