Class GThreadPool
 The simple behavior for when new tasks are submitted:
  1) If there any idle threads, use that thread.
  2) If all existing threads are busy and the number of threads is less than max threads, add a
     new thread and use it.
  3) if all threads are busy and there are max number of threads, queue the item until a thread
     becomes free.
 
 The simple behavior for when tasks are completed by a thread:
  1) If there are tasks in the queue, start processing a new item in the newly freed thread.
  2) if there are more threads that min threads, allow this thread to die if no new
     jobs arrive before
     the "KEEP ALIVE" time expires which is currently 15 seconds.
  3) if there are min threads or less, allow this thread to wait forever for a new job
     to arrive.
- 
Method SummaryModifier and TypeMethodDescriptionReturns theExecutorused by this thread pool.intReturns the maximum number of threads to use in this thread pool.intReturns the minimum number of threads to keep alive in this thread pool.static GThreadPoolgetPrivateThreadPool(String name) Creates a new, private thread pool with the given name.static GThreadPoolgetSharedThreadPool(String name) Returns a shared GThreadPool.booleanReturns true if this is not a shared thread pool.static CompletableFuture<Void> Runs the given runnable in a background thread using a shared thread pool of the given name.voidsetMaxThreadCount(int maxThreadCount) Sets the max number of threads to use in this thread pool.voidsetMinThreadCount(int minThreadCount) Sets the minimum number of threads to keep alive in this thread pool.voidFuture<?> Submits a runnable to be executed by this thread pool.<T> Future<T> Submits a runnable to be executed by this thread pool.<T> Future<T> Submits a callable to be executed by this thread pool.voidsubmit(FutureTask<?> futureTask) Submits a FutreTask to be executed by a thread in this thread pool.
- 
Method Details- 
getPrivateThreadPoolCreates a new, private thread pool with the given name.- Parameters:
- name- the name of the thread pool
- Returns:
- a private GThreadPool with the given name.
 
- 
runAsyncRuns the given runnable in a background thread using a shared thread pool of the given name.- Parameters:
- poolName- the thread pool name
- r- the runnable
- Returns:
- the future
 
- 
setMaxThreadCountpublic void setMaxThreadCount(int maxThreadCount) Sets the max number of threads to use in this thread pool. The default is the number of processors + 1.- Parameters:
- maxThreadCount- the maximum number of threads to use in this thread pool.
 
- 
getMinThreadCountpublic int getMinThreadCount()Returns the minimum number of threads to keep alive in this thread pool.- Returns:
- the minimum number of threads to keep alive in this thread pool.
 
- 
setMinThreadCountpublic void setMinThreadCount(int minThreadCount) Sets the minimum number of threads to keep alive in this thread pool.- Parameters:
- minThreadCount- the minimum number of threads to keep alive in this thread pool.
 
- 
getMaxThreadCountpublic int getMaxThreadCount()Returns the maximum number of threads to use in this thread pool.- Returns:
- the maximum number of threads to use in this thread pool.
 
- 
submitSubmits a FutreTask to be executed by a thread in this thread pool.- Parameters:
- futureTask- the future task to be executed.
 
- 
submitSubmits a runnable to be executed by this thread pool.- Parameters:
- task- the runnable to be executed.
- Returns:
- a Future for that runnable.
 
- 
submitSubmits a runnable to be executed by this thread pool.- Parameters:
- task- the runnable to be executed.
- result- the result to be returned after the runnable has executed.
- Returns:
- a Future for that runnable.
 
- 
submitSubmits a callable to be executed by this thread pool.- Parameters:
- task- the callable to be executed.
- Returns:
- a Future for that callable.
 
- 
shutdownNowpublic void shutdownNow()
- 
isPrivatepublic boolean isPrivate()Returns true if this is not a shared thread pool.- Returns:
- true if this is not a shared thread pool.
 
- 
getExecutorReturns theExecutorused by this thread pool.Note: normal usage of this thread pool contraindicates accessing the executor of this pool. For managing your own jobs, you should use the method on this class directly. The intent of this method is to provide access to the executor so that it may be passed to other asynchronous APIs, such as the CompletableFuture.- Returns:
- the executor
 
 
-