Question

The getQueue() method provides access to the underlying blocking queue in the ThreadPoolExecutor, but this does not seem to be safe.

A traversal over the queue returned by this function might miss updates made to the queue by the ThreadPoolExecutor.

"Method getQueue() allows access to the work queue for purposes of monitoring and debugging. Use of this method for any other purpose is strongly discouraged."

What would you do if you wanted to traverse the workQueue used by the ThreadPoolExecutor? Or is there an alternate approach?

This is a continuation of.. Choosing a data structure for a variant of producer consumer problem

Now, I am trying the multiple producer multiple consumer, but I want to use some existing threadpool, since I don't want to manage the threadpool myself, and also I want a callback when ThreadPoolExecutor has finished executing some task alongwith the ability to examine in a thread safe way the "inprogress transactions" data structure.

No correct solution

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top