/// <summary>
 /// Creates the BlockingQueue and the ThreadPoolExecutor.
 /// </summary>
 public void Initialize() {
     if(logger.IsInfoEnabled) {
         logger.Info("Initializing ThreadPoolExecutor" + (_objectName != null ? " '" + _objectName + "'" : ""));
     }
     if(!_threadNamePrefixSet && _objectName != null) {
         ThreadNamePrefix = _objectName + "-";
     }
     IBlockingQueue<IRunnable> queue = CreateQueue(_queueCapacity);
     _threadPoolExecutor = new ThreadPoolExecutor(_corePoolSize, _maxPoolSize, _keepAliveTime, queue, _threadFactory, _rejectedExecutionHandler);
     if(_allowCoreThreadTimeOut) {
         _threadPoolExecutor.AllowsCoreThreadsToTimeOut = true;
     }
 }
예제 #2
0
 /// <summary>
 /// Default Constructor
 /// </summary>
 /// <param name="firstTask">Task to run before entering run loop.</param>
 /// <param name="parentThreadPoolExecutor"><see cref="Spring.Threading.Execution.ThreadPoolExecutor"/> that controls this worker</param>
 internal Worker(ThreadPoolExecutor parentThreadPoolExecutor, IRunnable firstTask)
 {
     FirstTask = firstTask;
     _parentThreadPoolExecutor = parentThreadPoolExecutor;
     Thread = parentThreadPoolExecutor.ThreadFactory.NewThread(this);
 }