Gregg is mostly right about the max number of threads and is probably commenting from experience. MaxThreads is not a hard limit. Will have to look into it further though to determine if it can be used for DOS, it doesn't look like it indefinitely increases the number of threads, but it is designed to prevent thread starvation deadlock.

/** Return true if a new thread should be created (ignoring maxThreads). */
   protected boolean needThread()

TaskManager is quite clever. I don't think TaskThread should be a Runnable rather than a Thread, Task is the Runnable. TaskThread is used to run the Runnable Task.

Try out ConcurrentDynamicPolicyProvider first, then we'll look at how to improve it, if needed.

When I look at how Policy, PermissionCollection and Permission was designed, it would have been so much cleaner if PermissionCollection were immutable.

Cheers,

Peter.

Peter Firmstone wrote:
Dennis Reedy wrote:
Anytime that you need more than corePoolSize threads, you risk seeing a task not being executed immediately. The fact that there is a maximumPoolSize is the bigger issue though. Only that many total threads can ever be running. If you know enough about all parts of all services and clients using your River application, you might be able to accurately guess what maximumPoolSize would need to be. But ultimately, in a distributed application where circular invocation scenarios are possible, you need a lot of information and there has to be a lot of control in the applications to make sure that there are never more than maximumPoolSize simultaneous method invocations in an instance.

I don't think that is possible, nor really a good idea to have a maximumPoolSize. A thread pool design, like TaskManager, where only a minimum exists, is the type of design we need in River.

Not sure I agree with this. You should _always_ have an upper bound, you cannot assume that you have limitless resources. Just creating threads because an application "says so", is generally not advisable, and can lead to OOME as well as DOS issues.
Ditto.

   /**
    * Create a task manager with maxThreads = 10, timeout = 15 seconds,
    * and loadFactor = 3.0.
    */
   public TaskManager() {
   this(10, 1000 * 15, 3.0f);
   }

public TaskManager(int maxThreads, long timeout, float loadFactor)

Cheers,

Peter.


Reply via email to