Class ThreadPoolConfig


  • public final class ThreadPoolConfig
    extends Object
    Grizzly thread-pool configuration, which might be used to create and initialize a thread-pool via GrizzlyExecutorService.createInstance(org.glassfish.grizzly.threadpool.ThreadPoolConfig). One can get a default Grizzly ThreadPoolConfig using copy() and customize it according to the application specific requirements. A ThreadPoolConfig object might be customized in a "Builder"-like fashion: ThreadPoolConfig.defaultConfig() .setPoolName("App1Pool") .setCorePoolSize(5) .setMaxPoolSize(10);
    Author:
    Oleksiy Stashok, gustav trede
    • Field Detail

      • poolName

        protected String poolName
      • corePoolSize

        protected int corePoolSize
      • maxPoolSize

        protected int maxPoolSize
      • queueLimit

        protected int queueLimit
      • keepAliveTimeMillis

        protected long keepAliveTimeMillis
      • priority

        protected int priority
      • isDaemon

        protected boolean isDaemon
      • transactionTimeoutMillis

        protected long transactionTimeoutMillis
      • initialClassLoader

        protected ClassLoader initialClassLoader
    • Method Detail

      • defaultConfig

        public static ThreadPoolConfig defaultConfig()
        Create new Grizzly thread-pool configuration instance. The returned ThreadPoolConfig instance will be pre-configured with a default values.
        Returns:
        the Grizzly thread-pool configuration instance.
      • getQueue

        public Queue<Runnable> getQueue()
        Returns:
        the queue
      • getPoolName

        public String getPoolName()
        Returns:
        the poolname
      • getPriority

        public int getPriority()
      • isDaemon

        public boolean isDaemon()
      • getMaxPoolSize

        public int getMaxPoolSize()
        Returns:
        the maxpoolsize
      • setMaxPoolSize

        public ThreadPoolConfig setMaxPoolSize​(int maxPoolSize)
        Parameters:
        maxPoolSize - the max thread pool size
        Returns:
        the ThreadPoolConfig with the new max pool size
      • getCorePoolSize

        public int getCorePoolSize()
        Returns:
        the corepoolsize
      • setCorePoolSize

        public ThreadPoolConfig setCorePoolSize​(int corePoolSize)
        Parameters:
        corePoolSize - the core thread pool size
        Returns:
        the ThreadPoolConfig with the new core pool size
      • getQueueLimit

        public int getQueueLimit()
        Returns:
        the thread-pool queue limit. The queue limit value less than 0 means unlimited queue.
      • setQueueLimit

        public ThreadPoolConfig setQueueLimit​(int queueLimit)
        Parameters:
        queueLimit - the thread-pool queue limit. The queueLimit value less than 0 means unlimited queue.
        Returns:
        the ThreadPoolConfig with the new queue limite
      • setKeepAliveTime

        public ThreadPoolConfig setKeepAliveTime​(long time,
                                                 TimeUnit unit)
        The max period of time a thread will wait for a new task to process. If the timeout expires and the thread is not a core one (see setCorePoolSize(int), setMaxPoolSize(int)) - then the thread will be terminated and removed from the thread pool.
        Parameters:
        time - max keep alive timeout. The value less than 0 means no timeout
        unit - time unit
        Returns:
        the ThreadPoolConfig with the new keep alive time
      • getKeepAliveTime

        public long getKeepAliveTime​(TimeUnit timeUnit)
        Returns the max period of time a thread will wait for a new task to process. If the timeout expires and the thread is not a core one (see setCorePoolSize(int), setMaxPoolSize(int)) - then the thread will be terminated and removed from the thread pool.
        Returns:
        the keep-alive timeout, the value less than 0 means no timeout
      • getTransactionTimeout

        public long getTransactionTimeout​(TimeUnit timeUnit)
      • setTransactionTimeout

        public ThreadPoolConfig setTransactionTimeout​(long transactionTimeout,
                                                      TimeUnit timeunit)
      • getInitialClassLoader

        public ClassLoader getInitialClassLoader()
        Returns:
        the classloader (if any) to be initially exposed by threads from this pool.
        Since:
        2.3
      • setInitialClassLoader

        public ThreadPoolConfig setInitialClassLoader​(ClassLoader initialClassLoader)
        Specifies the context classloader that will be used by threads in this pool. If not specified, the classloader of the parent thread that initialized the pool will be used.
        Parameters:
        initialClassLoader - the classloader to be exposed by threads of this pool.
        Returns:
        the ThreadPoolConfig
        Since:
        2.3
        See Also:
        Thread.getContextClassLoader()