summaryrefslogtreecommitdiff
path: root/same/src/main/java
diff options
context:
space:
mode:
Diffstat (limited to 'same/src/main/java')
-rw-r--r--same/src/main/java/com/orbekk/util/WorkQueue.java12
1 files changed, 12 insertions, 0 deletions
diff --git a/same/src/main/java/com/orbekk/util/WorkQueue.java b/same/src/main/java/com/orbekk/util/WorkQueue.java
index 4eb54f5..2fb2c88 100644
--- a/same/src/main/java/com/orbekk/util/WorkQueue.java
+++ b/same/src/main/java/com/orbekk/util/WorkQueue.java
@@ -38,6 +38,18 @@ abstract public class WorkQueue<E> extends Thread implements List<E> {
* Called until the queue is empty.
*/
protected abstract void onChange();
+
+ /**
+ * Perform work until the queue is empty.
+ *
+ * Can be used for testing or for combining several WorkQueues in
+ * a single thread.
+ */
+ public synchronized void performWork() {
+ while (!isEmpty()) {
+ onChange();
+ }
+ }
@Override
public void run() {