com.sun.grizzly.util
Class GrizzlyExecutorService

java.lang.Object
  extended by java.util.concurrent.AbstractExecutorService
      extended by com.sun.grizzly.util.GrizzlyExecutorService
All Implemented Interfaces:
ExtendedThreadPool, Executor, ExecutorService
Direct Known Subclasses:
StatsThreadPool

public class GrizzlyExecutorService
extends AbstractExecutorService
implements ExtendedThreadPool

Author:
gustav trede

Field Summary
protected  ThreadPoolConfig config
           
 
Constructor Summary
protected GrizzlyExecutorService(ThreadPoolConfig config)
           
protected GrizzlyExecutorService(ThreadPoolConfig config, boolean initialize)
           
 
Method Summary
 boolean awaitTermination(long timeout, TimeUnit unit)
           
static GrizzlyExecutorService createInstance()
           
static GrizzlyExecutorService createInstance(ThreadPoolConfig cfg)
           
 void execute(Runnable r)
           
 int getActiveCount()
          Deprecated. please use ThreadPoolMonitoringProbes to intercept thread pool events and build statistics.
 long getCompletedTaskCount()
          Deprecated. please use ThreadPoolMonitoringProbes to intercept thread pool events and build statistics.
 ThreadPoolConfig getConfiguration()
           
 int getCorePoolSize()
          Deprecated. please use getConfiguration() to check thread pool configuration settings.
 long getKeepAliveTime(TimeUnit unit)
          Deprecated. please use getConfiguration() to check thread pool configuration settings.
 int getLargestPoolSize()
          Deprecated. please use ThreadPoolMonitoringProbes to intercept thread pool events and build statistics.
 int getMaximumPoolSize()
          Deprecated. please use getConfiguration() to check thread pool configuration settings.
 int getMaxQueuedTasksCount()
          Deprecated. please use getConfiguration() to check thread pool configuration settings.
 String getName()
          Deprecated. please use getConfiguration() to check thread pool configuration settings.
 int getPoolSize()
          Deprecated. please use ThreadPoolMonitoringProbes to intercept thread pool events and build statistics.
 int getPriority()
          Deprecated. please use getConfiguration() to check thread pool configuration settings.
 Queue<Runnable> getQueue()
          Deprecated. please use getConfiguration() to check thread pool configuration settings.
 int getQueueSize()
          Deprecated. please use ThreadPoolMonitoringProbes to intercept thread pool events and build statistics.
 int getTaskCount()
          Deprecated. please use ThreadPoolMonitoringProbes to intercept thread pool events and build statistics.
 ThreadFactory getThreadFactory()
          Deprecated. please use getConfiguration() to check thread pool configuration settings.
 boolean isShutdown()
           
 boolean isTerminated()
           
 GrizzlyExecutorService reconfigure(ThreadPoolConfig config)
          Sets the ThreadPoolConfig
 void setCorePoolSize(int corePoolSize)
          Deprecated. please use reconfigure(com.sun.grizzly.util.ThreadPoolConfig) to change thread pool configuration settings.
protected  void setImpl(ThreadPoolConfig cfg)
           
 void setKeepAliveTime(long time, TimeUnit unit)
          Deprecated. please use reconfigure(com.sun.grizzly.util.ThreadPoolConfig) to change thread pool configuration settings.
 void setMaximumPoolSize(int maximumPoolSize)
          Deprecated. please use reconfigure(com.sun.grizzly.util.ThreadPoolConfig) to change thread pool configuration settings.
 void setMaxQueuedTasksCount(int maxTasksCount)
          Deprecated. please use reconfigure(com.sun.grizzly.util.ThreadPoolConfig) to change thread pool configuration settings.
 void setName(String name)
          Deprecated. please use reconfigure(com.sun.grizzly.util.ThreadPoolConfig) to change thread pool configuration settings.
 void setPriority(int priority)
          Deprecated. please use reconfigure(com.sun.grizzly.util.ThreadPoolConfig) to change thread pool configuration settings.
 void setThreadFactory(ThreadFactory threadFactory)
          Deprecated. please use reconfigure(com.sun.grizzly.util.ThreadPoolConfig) to change thread pool configuration settings.
 void shutdown()
           
 List<Runnable> shutdownNow()
           
 
Methods inherited from class java.util.concurrent.AbstractExecutorService
invokeAll, invokeAll, invokeAny, invokeAny, newTaskFor, newTaskFor, submit, submit, submit
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface java.util.concurrent.ExecutorService
invokeAll, invokeAll, invokeAny, invokeAny, submit, submit, submit
 

Field Detail

config

protected volatile ThreadPoolConfig config
Constructor Detail

GrizzlyExecutorService

protected GrizzlyExecutorService(ThreadPoolConfig config)

GrizzlyExecutorService

protected GrizzlyExecutorService(ThreadPoolConfig config,
                                 boolean initialize)
Method Detail

createInstance

public static GrizzlyExecutorService createInstance()
Returns:
GrizzlyExecutorService

createInstance

public static GrizzlyExecutorService createInstance(ThreadPoolConfig cfg)
Parameters:
cfg - ThreadPoolConfig
Returns:
GrizzlyExecutorService

setImpl

protected final void setImpl(ThreadPoolConfig cfg)

reconfigure

public GrizzlyExecutorService reconfigure(ThreadPoolConfig config)
Sets the ThreadPoolConfig

Parameters:
config -
Returns:
returns GrizzlyExecutorService

getConfiguration

public ThreadPoolConfig getConfiguration()
Returns:
config - ThreadPoolConfig

shutdown

public void shutdown()
Specified by:
shutdown in interface ExecutorService

shutdownNow

public List<Runnable> shutdownNow()
Specified by:
shutdownNow in interface ExecutorService

isShutdown

public boolean isShutdown()
Specified by:
isShutdown in interface ExecutorService

isTerminated

public boolean isTerminated()
Specified by:
isTerminated in interface ExecutorService

execute

public void execute(Runnable r)
Specified by:
execute in interface Executor

awaitTermination

public boolean awaitTermination(long timeout,
                                TimeUnit unit)
                         throws InterruptedException
Specified by:
awaitTermination in interface ExecutorService
Throws:
InterruptedException

getQueue

@Deprecated
public Queue<Runnable> getQueue()
Deprecated. please use getConfiguration() to check thread pool configuration settings.

Description copied from interface: ExtendedThreadPool
Returns the task queue used by this executor. Access to the task queue is intended primarily for debugging and monitoring. This queue may be in active use. Retrieving the task queue does not prevent queued tasks from executing.

Specified by:
getQueue in interface ExtendedThreadPool
Returns:
the task queue

getActiveCount

@Deprecated
public int getActiveCount()
Deprecated. please use ThreadPoolMonitoringProbes to intercept thread pool events and build statistics.

Description copied from interface: ExtendedThreadPool
Returns the approximate number of threads that are actively executing tasks.

Specified by:
getActiveCount in interface ExtendedThreadPool
Returns:
the number of threads

getTaskCount

@Deprecated
public int getTaskCount()
Deprecated. please use ThreadPoolMonitoringProbes to intercept thread pool events and build statistics.

Description copied from interface: ExtendedThreadPool
Returns the approximate total number of tasks that have been scheduled for execution. Because the states of tasks and threads may change dynamically during computation, the returned value is only an approximation, but one that does not ever decrease across successive calls.

Specified by:
getTaskCount in interface ExtendedThreadPool
Returns:
the number of tasks

getCompletedTaskCount

@Deprecated
public long getCompletedTaskCount()
Deprecated. please use ThreadPoolMonitoringProbes to intercept thread pool events and build statistics.

Description copied from interface: ExtendedThreadPool
Returns the approximate total number of tasks that have completed execution. Because the states of tasks and threads may change dynamically during computation, the returned value is only an approximation, but one that does not ever decrease across successive calls.

Specified by:
getCompletedTaskCount in interface ExtendedThreadPool
Returns:
the number of tasks

getCorePoolSize

@Deprecated
public int getCorePoolSize()
Deprecated. please use getConfiguration() to check thread pool configuration settings.

Description copied from interface: ExtendedThreadPool
Returns the core number of threads.

Specified by:
getCorePoolSize in interface ExtendedThreadPool
Returns:
the core number of threads
See Also:
ExtendedThreadPool.setCorePoolSize(int)

setCorePoolSize

@Deprecated
public void setCorePoolSize(int corePoolSize)
Deprecated. please use reconfigure(com.sun.grizzly.util.ThreadPoolConfig) to change thread pool configuration settings.

Description copied from interface: ExtendedThreadPool
Sets the core number of threads. This overrides any value set in the constructor. If the new value is smaller than the current value, excess existing threads will be terminated when they next become idle. If larger, new threads will, if needed, be started to execute any queued tasks.

Specified by:
setCorePoolSize in interface ExtendedThreadPool
Parameters:
corePoolSize - the new core size
See Also:
ExtendedThreadPool.getCorePoolSize()

getLargestPoolSize

@Deprecated
public int getLargestPoolSize()
Deprecated. please use ThreadPoolMonitoringProbes to intercept thread pool events and build statistics.

Description copied from interface: ExtendedThreadPool
Returns the largest number of threads that have ever simultaneously been in the pool.

Specified by:
getLargestPoolSize in interface ExtendedThreadPool
Returns:
the number of threads

getPoolSize

@Deprecated
public int getPoolSize()
Deprecated. please use ThreadPoolMonitoringProbes to intercept thread pool events and build statistics.

Description copied from interface: ExtendedThreadPool
Returns the current number of threads in the pool.

Specified by:
getPoolSize in interface ExtendedThreadPool
Returns:
the number of threads

getQueueSize

@Deprecated
public int getQueueSize()
Deprecated. please use ThreadPoolMonitoringProbes to intercept thread pool events and build statistics.

Description copied from interface: ExtendedThreadPool
Returns the number of tasks, which are currently waiting in the queue.

Specified by:
getQueueSize in interface ExtendedThreadPool
Returns:
the number of tasks, which are currently waiting in the queue.

getKeepAliveTime

@Deprecated
public long getKeepAliveTime(TimeUnit unit)
Deprecated. please use getConfiguration() to check thread pool configuration settings.

Description copied from interface: ExtendedThreadPool
Returns the thread keep-alive time, which is the amount of time which threads in excess of the core pool size may remain idle before being terminated.

Specified by:
getKeepAliveTime in interface ExtendedThreadPool
Parameters:
unit - the desired time unit of the result
Returns:
the time limit
See Also:
ExtendedThreadPool.setKeepAliveTime(long, java.util.concurrent.TimeUnit)

setKeepAliveTime

@Deprecated
public void setKeepAliveTime(long time,
                                        TimeUnit unit)
Deprecated. please use reconfigure(com.sun.grizzly.util.ThreadPoolConfig) to change thread pool configuration settings.

Description copied from interface: ExtendedThreadPool
Sets the time limit for which threads may remain idle before being terminated. If there are more than the core number of threads currently in the pool, after waiting this amount of time without processing a task, excess threads will be terminated. This overrides any value set in the constructor.

Specified by:
setKeepAliveTime in interface ExtendedThreadPool
Parameters:
time - the time to wait. A time value of zero will cause excess threads to terminate immediately after executing tasks.
unit - the time unit of the time argument
See Also:
ExtendedThreadPool.getKeepAliveTime(java.util.concurrent.TimeUnit)

getMaximumPoolSize

@Deprecated
public int getMaximumPoolSize()
Deprecated. please use getConfiguration() to check thread pool configuration settings.

Description copied from interface: ExtendedThreadPool
Returns the maximum allowed number of threads.

Specified by:
getMaximumPoolSize in interface ExtendedThreadPool
Returns:
the maximum allowed number of threads
See Also:
ExtendedThreadPool.setMaximumPoolSize(int)

setMaximumPoolSize

@Deprecated
public void setMaximumPoolSize(int maximumPoolSize)
Deprecated. please use reconfigure(com.sun.grizzly.util.ThreadPoolConfig) to change thread pool configuration settings.

Description copied from interface: ExtendedThreadPool
Sets the maximum allowed number of threads. This overrides any value set in the constructor. If the new value is smaller than the current value, excess existing threads will be terminated when they next become idle.

Specified by:
setMaximumPoolSize in interface ExtendedThreadPool
Parameters:
maximumPoolSize - the new maximum
See Also:
ExtendedThreadPool.getMaximumPoolSize()

getMaxQueuedTasksCount

@Deprecated
public int getMaxQueuedTasksCount()
Deprecated. please use getConfiguration() to check thread pool configuration settings.

Specified by:
getMaxQueuedTasksCount in interface ExtendedThreadPool

setMaxQueuedTasksCount

@Deprecated
public void setMaxQueuedTasksCount(int maxTasksCount)
Deprecated. please use reconfigure(com.sun.grizzly.util.ThreadPoolConfig) to change thread pool configuration settings.

Specified by:
setMaxQueuedTasksCount in interface ExtendedThreadPool

getName

@Deprecated
public String getName()
Deprecated. please use getConfiguration() to check thread pool configuration settings.

Specified by:
getName in interface ExtendedThreadPool

setName

@Deprecated
public void setName(String name)
Deprecated. please use reconfigure(com.sun.grizzly.util.ThreadPoolConfig) to change thread pool configuration settings.

Specified by:
setName in interface ExtendedThreadPool

getPriority

@Deprecated
public int getPriority()
Deprecated. please use getConfiguration() to check thread pool configuration settings.

Specified by:
getPriority in interface ExtendedThreadPool

setPriority

public void setPriority(int priority)
Deprecated. please use reconfigure(com.sun.grizzly.util.ThreadPoolConfig) to change thread pool configuration settings.

Specified by:
setPriority in interface ExtendedThreadPool

getThreadFactory

@Deprecated
public ThreadFactory getThreadFactory()
Deprecated. please use getConfiguration() to check thread pool configuration settings.

Description copied from interface: ExtendedThreadPool
Returns the thread factory used to create new threads.

Specified by:
getThreadFactory in interface ExtendedThreadPool
Returns:
the current thread factory
See Also:
ExtendedThreadPool.setThreadFactory(java.util.concurrent.ThreadFactory)

setThreadFactory

@Deprecated
public void setThreadFactory(ThreadFactory threadFactory)
Deprecated. please use reconfigure(com.sun.grizzly.util.ThreadPoolConfig) to change thread pool configuration settings.

Description copied from interface: ExtendedThreadPool
Sets the thread factory used to create new threads.

Specified by:
setThreadFactory in interface ExtendedThreadPool
Parameters:
threadFactory - the new thread factory
See Also:
ExtendedThreadPool.getThreadFactory()


Copyright © 2012 Oracle Corporation. All Rights Reserved.