Asynchronous execution in BlockingQueue

强颜欢笑 提交于 2019-12-13 19:33:30

问题


I am using Java collections BlockingQueue for data processing. The current code looks like

while(true){
    if(queue.size() > 0)
        handle(queue.take())
}

Is there a way (in Java or other frameworks) where I can process it asynchronously, like,

queue.setHandler(new Handler<E>());

somewhere down the class..

class Handler implements IHandler<E>{
    void handle(E e){
        handle(e)
    }
}

来源:https://stackoverflow.com/questions/32793159/asynchronous-execution-in-blockingqueue

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!