4
동시 프로그램에서 경쟁 조건을 지키지 않고 BlockingQueue에서 개체를 가져 오는 가장 좋은 방법은 무엇입니까? 이 정말 안전한지 나도 확실히 아무도는 아니지만,동시 프로그램의 BlockingQueue에서 객체를 가져 오는 가장 좋은 방법은 무엇입니까?
BlockingQueue<Violation> vQueue;
/*
in the constructor I pass in a BlockingQueue object
full of violations that need to be processed - cut out for brevity
*/
Violation v;
while ((v = vQueue.poll(500, TimeUnit.MILLISECONDS)) != null) {
// do stuff with the violation
}
내가 경쟁 조건을 칠 아직 ...하지만 : 저는 현재 다음을 수행하고 있는데 나는 그것이 최선의 방법입니다 확신 아니에요 .