I have a flow of units of work, lets call them \"Work Items\" that are processed sequentially (for now). I\'d like to speed up processing by doing the work multithreaded.
<
If you allow BlockingQueue
, why would you ignore the rest of the concurrency utils in java?
You could use e.g. Stream
(if you have java 1.8) for the above:
List data = ...;
List out = data.parallelStream()
.map(t -> doSomeWork(t))
.collect(Collectors.toList());
Because you started from an ordered Collection
(List
), and collect also to a List
, you will have results in the same order as the input.