Class SerialExecutor

java.lang.Object
org.apache.felix.dm.runtime.SerialExecutor

public final class SerialExecutor extends Object
Allows you to enqueue tasks from multiple threads and then execute them on one thread sequentially. It assumes more than one thread will try to execute the tasks and it will make an effort to pick the first task that comes along whilst making sure subsequent tasks return without waiting.
Author:
Felix Project Team
  • Constructor Details

    • SerialExecutor

      public SerialExecutor()
  • Method Details

    • enqueue

      public void enqueue(Runnable runnable)
      Enqueue a new task for later execution. This method is thread-safe, so multiple threads can contribute tasks.
      Parameters:
      runnable - the runnable containing the actual task
    • execute

      public void execute()
      Execute any pending tasks. This method is thread safe, so multiple threads can try to execute the pending tasks, but only the first will be used to actually do so. Other threads will return immediately.