Code example for BlockingQueue

Methods: put

0
        int value = (int) (Math.random() * 1000);
         
        LOGGER.info("Generated Integer Value = " + value);
         
        try { 
            channel.put(value);
        } catch (InterruptedException e) {
        } 
    } 
     
    @Scheduled(cron="*/5 * * * * *") 
    public void printInteger() { 
        while (!channel.isEmpty()) {
            LOGGER.info("Retrieved Integer: " + channel.poll());
        } 
    } 
}