com.bbn.openmap.util
Class TaskService

java.lang.Object
  extended by com.bbn.openmap.util.TaskService

public final class TaskService
extends java.lang.Object

Reuse threads instead of making new ones over and over.


Method Summary
 void setExecutorService(java.util.concurrent.ExecutorService eService)
          Allows more control over how threads can be allocated.
 void setMaxNumThreads(int maxNumThreads)
          If called, will replace the default unbounded executor using a cached thread pool with a fixed thread pool executor, so the maxNumThreads are allocated.
static TaskService singleton()
           
<T> java.util.concurrent.Future<T>
spawn(java.util.concurrent.Callable<T> task)
           
 void spawn(java.lang.Runnable task)
          Run a task in a thread.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

singleton

public static TaskService singleton()

spawn

public void spawn(java.lang.Runnable task)
Run a task in a thread.

Parameters:
task - the runnable

spawn

public <T> java.util.concurrent.Future<T> spawn(java.util.concurrent.Callable<T> task)

setExecutorService

public void setExecutorService(java.util.concurrent.ExecutorService eService)
Allows more control over how threads can be allocated.

Parameters:
eService - ExecutorService that allocates and schedules thread spawning for layers.

setMaxNumThreads

public void setMaxNumThreads(int maxNumThreads)
If called, will replace the default unbounded executor using a cached thread pool with a fixed thread pool executor, so the maxNumThreads are allocated. If they are all busy, the Runnables will queue.

Parameters:
maxNumThreads - number of threads to allocate for the thread pool


Copyright (C) BBNT Solutions LLC; See http://openmap.bbn.com/ for details