Source:
<code>private void sendNextNotification(final long timeout, final TimeUnit timeUnit) throws InterruptedException { final T notification; <START> synchronized(pushManager.getQueue()) { <END> notification = this.pushManager.getQueue().poll(timeout, timeUnit); pushManager.getQueue().notifyAll(); } if (this.isInterrupted()) { this.pushManager.enqueuePushNotification(notification, true); } else if (notification != null) { final SendableApnsPushNotification<T> sendableNotification = new SendableApnsPushNotification<T>(notification, this.sequenceNumber++); final String threadName = this.getName(); if (log.isTraceEnabled()) { log.trace(String.format("%s sending %s", threadName, sendableNotification)); } this.sentNotificationBuffer.addSentNotification(sendableNotification); this.channel.write(sendableNotification).addListener(new GenericFutureListener<ChannelFuture>() { public void operationComplete(final ChannelFuture future) { if (future.cause() != null) { if (log.isTraceEnabled()) { log.trace(String.format("%s failed to write notification %s", threadName, sendableNotification), future.cause()); } requestReconnection(); final T failedNotification = sentNotificationBuffer.getAndRemoveNotificationWithSequenceNumber( sendableNotification.getSequenceNumber()); if (failedNotification != null) { pushManager.enqueuePushNotification(failedNotification, true); } } else { if (log.isTraceEnabled()) { log.trace(String.format("%s successfully wrote notification %d", threadName, sendableNotification.getSequenceNumber())); } } } }); this.hasEverSentNotification = true; if (++this.writesSinceLastFlush >= ApnsClientThread.BATCH_SIZE) { this.channel.flush(); this.writesSinceLastFlush = 0; } } else { if (this.writesSinceLastFlush > 0) { this.channel.flush(); this.writesSinceLastFlush = 0; } } }</code><technical_language>confused; do need synchronize a [BlockingQueue](<LINK_0></technical_language>

Target:
private void sendNextNotification(final long timeout, final TimeUnit timeUnit) throws InterruptedException { final T notification = this.pushManager.getQueue().poll(timeout, timeUnit); if (this.isInterrupted()) { this.pushManager.enqueuePushNotification(notification, true); } else if (notification != null) { final SendableApnsPushNotification<T> sendableNotification = new SendableApnsPushNotification<T>(notification, this.sequenceNumber++); final String threadName = this.getName(); if (log.isTraceEnabled()) { log.trace(String.format("%s sending %s", threadName, sendableNotification)); } this.sentNotificationBuffer.addSentNotification(sendableNotification); this.channel.write(sendableNotification).addListener(new GenericFutureListener<ChannelFuture>() { public void operationComplete(final ChannelFuture future) { synchronized(pushManager.getQueue()) { pushManager.getQueue().notifyAll(); } if (future.cause() != null) { if (log.isTraceEnabled()) { log.trace(String.format("%s failed to write notification %s", threadName, sendableNotification), future.cause()); } requestReconnection(); final T failedNotification = sentNotificationBuffer.getAndRemoveNotificationWithSequenceNumber( sendableNotification.getSequenceNumber()); if (failedNotification != null) { pushManager.enqueuePushNotification(failedNotification, true); } } else { if (log.isTraceEnabled()) { log.trace(String.format("%s successfully wrote notification %d", threadName, sendableNotification.getSequenceNumber())); } } } }); this.hasEverSentNotification = true; if (++this.writesSinceLastFlush >= ApnsClientThread.BATCH_SIZE) { this.channel.flush(); this.writesSinceLastFlush = 0; } } else { if (this.writesSinceLastFlush > 0) { this.channel.flush(); this.writesSinceLastFlush = 0; } } }