为什么我的可运行接口循环我的队列在这里继续

why my Runnable Interface Looping my Queue Continue here

这里我想运行我的所有列表a,如果一个元素b.poll()(从队列中删除并使用它),限制大小为Queue b它再次添加一个。来自 List a 的元素等等....

我已经尝试了多种停止循环的方法。

public class BroadcastThreadInitializerProcessor implements Runnable {
@Autowired
private NetworkInterfaceServiceInterface networkInterfaceServiceInterface;

private volatile boolean running = true;
private volatile boolean paused = false;

private VoiceBroadcast voiceBroadcast =null;

List<ExcelDatas> a = null;

public BroadcastThreadInitializerProcessor(VoiceBroadcast voiceBroadcast, UploadExcel uploadExcel ) {
    this.voiceBroadcast=voiceBroadcast;
            this.a = uploadExcel.getExcelDatas();
}

@Override
public void run() {
     while (running){
        synchronized (a) {
            if (!running) { 
                break;
            }
            if (paused) {
                try {
                    a.wait(); 
                } catch (InterruptedException ex) {
                     break;
                }
                if (!running) { // running might have changed since we paused
                    break;
                }
            }
        }//syncronized stop

     // Broadcasting code START here...
        int channels = Integer.parseInt(voiceBroadcast.getChannel());
        try {
         Queue<ExcelDatas> b = null;
         int aIndex  = 0;
         if(a.size()> channels){  //load elements in Queue
             b = new LinkedList<>();
             for (int i = 0; i < channels ; i++) {
                 b.add(a.get(aIndex));
                 aIndex++;
             }
         }else {
             b = new LinkedList<>(a); //load all elements
         }
          Client client = new Client();
            client.connect("",  , "", 10); 
            client.setEventSubscriptions( "", "" );
            boolean looping = true;

    while (looping) {   //looping while

        if (paused) {
          a.wait();
        }
    if (!running) { looping=false; break;} // break when all call are completed
    if (b.isEmpty()) { running=false; break;} // break when all call are completed
    EslMessage chan = client.sendSyncApiCommand("show channels count","");
            int usedChannel = Integer.parseInt(Arrays.asList(chan.getBodyLines().toString().replaceAll("[^0-9]+"," ").trim().split(" ")).get(0));
         if(usedChannel<(channels-1)) {
             System.err.println("Used Channels "+usedChannel +" <--Total Channels"+channels);
                ExcelDatas frontValue = b.poll(); // get queue's first element and remove it
            String uuid = UUID.randomUUID().toString();

            if(frontValue.getContact().length()>=10) {
                  client.sendSyncApiCommand("",""); //for calling
                  System.err.println("Callling on "+frontValue.getContact()+" By clip number:-"+voiceBroadcast.getClip()+" with UUID:-"+uuid);
                }//if for Contact number

         //call Processs    Stop  
           if(a.size()> channels){
            if (aIndex  < a.size()) {
                b.add(a.get(aIndex++)); //Add of New Node in Queue
            }//inner if node set
           }//if upper
        //for close all loops if b is empty
    if(b.isEmpty()) {
      System.err.println("b is empty");
      running = false; 
      looping=false;
      break;
    }//if

            Thread.sleep(700);
     }//upper if   ports check

    }//Stop looping while loop

      looping=false;
      running = false; 
      client.close();
     }catch (Exception e) {

    }          

 // Broadcasting code STOP here...           
  }//while loop

 }//run() method STOP


// Actions methods Start
public void terminate() {
    running = false;
}

public void pause() {
   paused = true;
}

public void resume() {
    synchronized (a) {
        paused = false;
        a.notifyAll(); // Unblocks thread
    }
}
//Action Methods STOP   
}

但是我的代码的反应是第一个队列的大小是 运行 一次又一次地重复只有这些元素 (if a.size()>channel where channel is b.size()) 而它不会进入下一个元素 NOR Exit the while(looping).

任何人都可以 solve/explain/describe 吗?谢谢...

这里我改了一下,

private static  BlockingQueue<ExcelDatas> queue = null;
......
......
 queue = new ArrayBlockingQueue<>(channels);
.......
.......
ExcelDatas frontValue = queue.take();

它解决了我的问题,谢谢@AntoineMarques。