de.netseeker.ejoe.concurrent
Class ThreadPoolResizer

java.lang.Object
  extended by java.util.TimerTask
      extended by de.netseeker.ejoe.concurrent.ThreadPoolResizer
All Implemented Interfaces:
java.lang.Runnable

public final class ThreadPoolResizer
extends java.util.TimerTask

A controller thread which monitors a ThreadService and ensures that the limit of worker threads within the ThreadService will be adjusted according to the workload.

Since:
0.3.9.1
Author:
netseeker

Constructor Summary
ThreadPoolResizer(ThreadService pool, int maxPoolSize, long millisBeforeShrink)
          Creates a new instance of ThreadPoolResizer, which can be scheduled via using a Timer and will monitor and eventually resize the given ThreadService up to the given limit of workers by checking the workload of the pool.
 
Method Summary
 void run()
           
 
Methods inherited from class java.util.TimerTask
cancel, scheduledExecutionTime
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ThreadPoolResizer

public ThreadPoolResizer(ThreadService pool,
                         int maxPoolSize,
                         long millisBeforeShrink)
Creates a new instance of ThreadPoolResizer, which can be scheduled via using a Timer and will monitor and eventually resize the given ThreadService up to the given limit of workers by checking the workload of the pool. If the workload is very high in all checks during the given period (millisBeforeShrink) the amount of workers in the monitored ThreadService will be increased to a calculated size between 1 and the given limit of workers. If the workload is too low the amount of workers will get reduced.

Parameters:
pool - a ThreadService to monitor
maxPoolSize - the limit of worker threads for the ThreadService
millisBeforeShrink - the period before the ThreadService will get resized
Method Detail

run

public void run()
Specified by:
run in interface java.lang.Runnable
Specified by:
run in class java.util.TimerTask


Copyright © 2005-2007 netseeker. All Rights Reserved.