Being asynchronously notified of a BlockingQueue having an item available

前端 未结 3 840
隐瞒了意图╮
隐瞒了意图╮ 2021-02-19 18:22

I need an Object to be asynchronously notified when some BlockingQueue has got an item to give.

I\'ve searched both Javadoc and the web for a p

3条回答
  •  名媛妹妹
    2021-02-19 18:51

    Perhaps you could subclass some BlockingQueue (such as ArrayBlockingQueue or LinkedBlockingQueue or what ever you're using), add support for listeners and do

    @Override
    public boolean add(E o) {
        super.add(o);
        notifyListeners(o);
    }
    

提交回复
热议问题