org.apache.felix.dm.runtime
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
Method Summary |
void |
enqueue(Runnable runnable)
Enqueue a new task for later execution. |
void |
execute()
Execute any pending tasks. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
SerialExecutor
public SerialExecutor()
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.
Copyright © 2006-2011 Apache Software Foundation. All Rights Reserved.