Runnable locked (park) using ExecutorService and BlockingQueue

痞子三分冷 提交于 2020-01-25 04:18:06

问题


Note: I understand the rules site, but I can't to put all code (complex/large code). I wish I was more specific, but I don't know what part to extract and show. Before you close this question: Obviously, I am willing to refine my question if someone tells me where to look (technical detail).

I made a video in order to show my issue.

Even to formulate the question, I made a diagram to show the situation.

My program has a JTree, showing the relations between Worker.

I have a diagram interaction between threads controlling life with ExecutorService executorService = Executors.newCachedThreadPool(); and List<Future<?>> listFuture = Collections.synchronizedList(new ArrayList<>());

Each Runnable is started in this way listFuture().add(executorService().submit(this)); in its constructor. The lists are created like this: BlockingQueue<Custom> someBlockingQueue = new LinkedBlockingQueue<>();

My diagram shows who the Worker's father is if he has one. It also shows, the writing relationships between the BlockingQueue.

RunnableStopper stops related runnables contained in Worker like property. RunnableDecrementer, RunnableIncrementer, RunnableFilter operates with a cycle that runs each Custom that it receives for its BlockingQueue. For which they always create a RunnableProcessor (it has no loop, but because of its long processing, once the task is finished it should be collected by the GC).

Internally the RunnableIncrementer has a Map Map<Integer, List<Custom>> mapListDelayedCustom = new HashMap<>();//Collections.synchronizedMap(new HashMap<>());

When arrives some Custom... I need to obtain the List of lastReceivedCustom List<Custom> listDelayedCustom = mapListDelayedCustom.putIfAbsent(custom.getCode(), new ArrayList<>()); I'm controlling the Size (is not growing indefinitely).

My code stops working when I add the following lines:

if (listDelayedCustom.size() > SomeValue) {
  //No operation has yet been included in if sentence
}

But commenting the lines doesn't block

//if (listDelayedCustom.size() > SomeValue) {
//  //No operation has yet been included in if sentence
//}

What could be blocking my Runnable? It makes no sense that adding the lines indicated (Evaluate the size of a list: if sentence) above stops working.

Any advice to further specify my question?

来源:https://stackoverflow.com/questions/59231602/runnable-locked-park-using-executorservice-and-blockingqueue

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