Java 阻塞队列不是阻塞线程吗?

Java 阻塞队列不是阻塞线程吗?,java,blockingqueue,Java,Blockingqueue,我在程序中使用阻塞队列。。 其中,我的客户端thred轮询响应,服务器thred提供对队列的响应。我没有从客户端使用任何thread.sleep机制,因为我使用blockingqueue..但当我的服务器线程延迟将一些消息放入队列时,我从队列中删除空值。。 为什么会这样? 我的代码 private BlockingQueue applicationResponses=new LinkedBlockingQueue(); 客户 -------- 消息响应=applicationResponses.

我在程序中使用阻塞队列。。 其中,我的客户端thred轮询响应,服务器thred提供对队列的响应。我没有从客户端使用任何thread.sleep机制,因为我使用blockingqueue..但当我的服务器线程延迟将一些消息放入队列时,我从队列中删除空值。。 为什么会这样? 我的代码

private BlockingQueue applicationResponses=new LinkedBlockingQueue();
客户
--------
消息响应=applicationResponses.poll();
服务器;
applicationResponses.offer(消息);

使用
take
而不是
poll
-
take
将阻止线程直到对象准备就绪,而
poll
将在队列为空时返回null

使用
take
而不是
poll
-
take
将阻止线程直到对象准备就绪,然而,如果队列为空,
poll
将简单地返回null

private BlockingQueue<Message> applicationResponses=  new LinkedBlockingQueue<Message>();

client
--------
    Message response = applicationResponses.poll();

server;
    applicationResponses.offer(message);