I have a BlockingQueue of capacity 1. It stores the last price of a stock received. The price stays in the queue until the client polls the queue. I then have a method called `getLatestPrice()` which should return the latest price for the stock. My issue is that the latest price may not be in the queue if the client has not polled it yet. It may be in a blocked thread. What would be my best solution to return the latest price if it's being blocked? Thank you.

```
private final BlockingQueue<PriceUpdate> latest;
private final long pollTimeout = 2;
private TimeUnit pollTimeUnit = TimeUnit.SECONDS;

public SaveListener(int capacity) {
     latest = new ArrayBlockingQueue<PriceUpdate>(capacity, true);
}

public void newPrice(PriceUpdate priceUpdate) {
    try {
        latest.put(priceUpdate);
    } catch (InterruptedException e) {
        e.printStackTrace();
    }
}

public PriceUpdate getNewPrice() {
    try {
        return latest.poll(pollTimeout, pollTimeUnit);                  } 
catch (InterruptedException e) {
        return null;
    }
} 

```

`getLatestPrice()` calls `getNewPrice` however it is not returning any value though I know there is a value stored on the queue.