Threadsafe get method on queue that draws values from other queues?
Code Style

Java Code Style puts the open-brace at the end of the line, not the start of the next line. For example, you have:


            if(i == nextQueue)
            {



but that should be:

            if(i == nextQueue) {


Variable conventions

i as a variable name is a great idea, if the variable is the control integer in a for loop. In your case, I presume it is short for 'item', or something, but, a Queue, being called i is unconventional.

As it happens, the letter q is perfect as a substitute....

Now, your nextQueue variable is actually the lastQueue odd.

Function extraction

With synchronization, return-balues from methods are often a great help for readibility. Consider this code you have:


// Work on a copy of memberQueues
List&lt;Queue&lt;T&gt;&gt; memberQueuesCopy;

synchronized(memberQueues)
{ memberQueuesCopy = new ArrayList&lt;Queue&lt;T&gt;&gt;(memberQueues); }



Which should really be written as:

// Work on a copy of memberQueues
List&lt;Queue&lt;T&gt;&gt; memberQueuesCopy;

synchronized(memberQueues) {
    memberQueuesCopy = new ArrayList&lt;Queue&lt;T&gt;&gt;(memberQueues);
}


would be even better if written as:

private final List&lt;Queue&lt;T&gt;&gt; copyQueues() {
    synchronized(memberQueues) {
        return new ArrayList&lt;Queue&lt;T&gt;&gt;(memberQueues);
    }
}


and then:

// Work on a copy of memberQueues
List&lt;Queue&lt;T&gt;&gt; memberQueuesCopy = copyQueues();


Bugs

There are three bugs I should point out:


NoSuchElementException if memberQeues is empty:


  Queue nextQueue = memberQueuesCopy.get(memberQueuesCopy.size() - 1);

(and bug 3) NullPointerException if any of the queues are empty (in some combinations) (one bug on iComparable, the other on nextValueComparable):


T nextValue = nextQueue.peek();
Comparable nextValueComparable = keyGetter.getMember(nextValue);

  ....

    T iValue = i.peek();
    Comparable iComparable = keyGetter.getMember(iValue);

  ....

    if(nextValue == iValue &amp;&amp; nextValueComparable.equals(iComparable))

  ....

    if(iComparable.compareTo(nextValueComparable) &lt; 0)