LimeWire Collection Component API

org.limewire.collection
Class RRProcessingQueue

java.lang.Object
  extended by org.limewire.collection.RRProcessingQueue

public class RRProcessingQueue
extends Object

Executes Runnables in a round-robin order per queue ID.

    class Runner implements Runnable {
        final int item;

        Runner(int item) {
            this.item = item;
        }

        public void run() {
            try {
                Thread.sleep(150);
                System.out.println("Item: " + item);
            } catch (InterruptedException iex) {
                System.out.println(iex.toString());
            }
        }
    }       
    RRProcessingQueue rrpq = new RRProcessingQueue("sampleCodeRRProcessingQueue");

    rrpq.execute(new Runner(1), "Abby");
    rrpq.execute(new Runner(2), "Bob");
    rrpq.execute(new Runner(3), "Abby");
    rrpq.execute(new Runner(4), "Bob");
    rrpq.execute(new Runner(5), "Chris");

    try {
        Thread.sleep(1000);
    } catch (InterruptedException ignored) {}                

    Output:
        Item: 1
        Item: 2
        Item: 5
        Item: 3
        Item: 4
 


Constructor Summary
RRProcessingQueue(String name)
           
 
Method Summary
 void clear()
           
 void clear(Object name)
           
 void execute(Runnable runner, Object queueId)
           
protected  boolean moreTasks()
           
protected  Runnable next()
           
protected  void notifyAndStart()
          Notifies the waiting thread or starts a new one.
 int size()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

RRProcessingQueue

public RRProcessingQueue(String name)
Method Detail

execute

public void execute(Runnable runner,
                    Object queueId)

notifyAndStart

protected void notifyAndStart()
Notifies the waiting thread or starts a new one.


moreTasks

protected boolean moreTasks()

next

protected Runnable next()

size

public int size()

clear

public void clear()

clear

public void clear(Object name)

LimeWire Collection Component API

Copyright © 2009 Lime Wire LLC. All Rights Reserved.