Code example for LinkedBlockingQueue

0
 
  @Override 
  public Firehose connect() throws IOException 
  { 
    final IRCApi irc = new IRCApiImpl(false);
    final LinkedBlockingQueue<Pair<DateTime, ChannelPrivMsg>> queue = new LinkedBlockingQueue<Pair<DateTime, ChannelPrivMsg>>();
 
    irc.addListener(new VariousMessageListenerAdapter() {
      @Override 
      public void onChannelMessage(ChannelPrivMsg aMsg)
      { 
        try { 
          queue.put(Pair.of(DateTime.now(), aMsg));
        } catch(InterruptedException e) {
          throw new RuntimeException("interrupted adding message to queue", e);
        } 
      } 
    }); 
 
    log.info("connecting to irc server [%s]", host);
    irc.connect(