org.jgroups.protocols

## Class SCOPE.QueueThread

- java.lang.Object
- - org.jgroups.protocols.SCOPE.QueueThread

All Implemented Interfaces:
  java.lang.Runnable

Enclosing class:
  SCOPE

    protected class SCOPE.QueueThread
    extends java.lang.Object
    implements java.lang.Runnable

### Field Summary

Fields
`protected boolean` `first`
`protected SCOPE.MessageQueue` `queue`

### Constructor Summary

Constructors
Constructor and Description
`SCOPE.QueueThread(SCOPE.MessageQueue queue)`

### Method Summary

Methods
`void` `run()` Try to remove as many messages as possible from the queue and pass them up.

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

### Field Detail

#### queue

    protected final SCOPE.MessageQueue queue

#### first

    protected boolean first

### Constructor Detail

#### SCOPE.QueueThread

    public SCOPE.QueueThread(SCOPE.MessageQueue queue)

### Method Detail

#### run

    public void run()

Try to remove as many messages as possible from the queue and pass them up. The outer and inner loop and the size() check at the end prevent the following scenario:

     - Threads T1 and T2
     - T1 has the CAS
     - T1: remove() == null
     - T2: add()
     - T2: attempt to set the CAS: false, return
     - T1: set the CAS to false, return
     ==> Result: we have a message in the queue that nobody takes care of !

Specified by:
  `run` in interface `java.lang.Runnable`