Class BasicScheduledTaskService

    • Field Detail

      • DEFAULT_POOL_SIZE

        protected static final int DEFAULT_POOL_SIZE
        Default thread pool size.
        See Also:
        Constant Field Values
      • RUNNING_THREAD_NAME_PREFIX

        protected static final java.lang.String RUNNING_THREAD_NAME_PREFIX
        Name assigned to active threads.
      • IDLE_THREAD_NAME_PREFIX

        protected static final java.lang.String IDLE_THREAD_NAME_PREFIX
        Name assigned to idle threads.
      • activeTasks

        protected java.util.concurrent.ConcurrentLinkedQueue<java.lang.Runnable> activeTasks
        Tasks currently running.
    • Constructor Detail

      • BasicScheduledTaskService

        public BasicScheduledTaskService()
        Create a new scheduled task service. The thread pool size is from the WorldWind configuration file property AVKey.TASK_POOL_SIZE.
    • Method Detail

      • shutdown

        public void shutdown​(boolean immediately)
        Description copied from interface: ScheduledTaskService
        Shut down the service. If the immediate parameter is true, the service will attempt to stop all active tasks, and will not begin work on any other tasks in the queue. Otherwise, the service will complete all tasks in the work queue, but will not accept any new tasks.
        Specified by:
        shutdown in interface ScheduledTaskService
        Parameters:
        immediately - true to shutdown immediately.
      • uncaughtException

        public void uncaughtException​(java.lang.Thread thread,
                                      java.lang.Throwable throwable)
        Specified by:
        uncaughtException in interface java.lang.Thread.UncaughtExceptionHandler
      • addTask

        public void addTask​(java.lang.Runnable runnable)
        Enqueues a task to run. Duplicate tasks are ignored.
        Specified by:
        addTask in interface ScheduledTaskService
        Parameters:
        runnable - the task to add
      • addScheduledTask

        public java.util.concurrent.ScheduledFuture<?> addScheduledTask​(java.lang.Runnable runnable,
                                                                        long delay,
                                                                        java.util.concurrent.TimeUnit timeunit)
        Enqueues a task to run after a delay. Duplicate tasks are ignored.
        Specified by:
        addScheduledTask in interface ScheduledTaskService
        Parameters:
        runnable - the task to add.
        delay - delay before execution of the task. timeUnit determines the units of the value.
        timeunit - time unit of initialDelay and period.
        Returns:
        a ScheduledFuture that can be used to get the result of the task, or cancel the task, or null if the task was not enqueued.
      • addRepeatingTask

        public java.util.concurrent.ScheduledFuture<?> addRepeatingTask​(java.lang.Runnable runnable,
                                                                        long initialDelay,
                                                                        long period,
                                                                        java.util.concurrent.TimeUnit timeunit)
        Enqueues a task to run periodically. This method follows the same semantics as ScheduledExecutorService.scheduleAtFixedRate(java.lang.Runnable, long, long, java.util.concurrent.TimeUnit). Duplicate tasks are ignored.
        Specified by:
        addRepeatingTask in interface ScheduledTaskService
        Parameters:
        runnable - the task to add.
        initialDelay - delay before the first execution of the task. timeUnit determines the units of the value.
        period - interval between executions of the task. timeUnit determines the units of the value.
        timeunit - time unit of initialDelay and period.
        Returns:
        a ScheduledFuture that can be used to get the result of the task, or cancel the task, or null if the task was not enqueued.