[英]What is the best way to process a object list at the same time by different classes
I am trying to process a object list at the same time with different classes, but I am not sure if I am heading in the right direction. 我正在尝试同时使用不同的类处理对象列表,但是我不确定是否朝着正确的方向前进。 I have read up about ExecutorService and Parallel stream, but not sure if it is the correct way. 我已经阅读了有关ExecutorService和Parallel流的信息,但不确定它是否正确。
So to provide an example: 所以举个例子:
I have a publisher that collects data and places it in a list. 我有一个收集数据并将其放置在列表中的发布者。 The publisher has multiple subscribers linked to it, which need to process the data and store it in a map. 发布者有多个与其链接的订户,这些订户需要处理数据并将其存储在地图中。 The map is then built up until all the data is processed and is then stored in a database table. 然后构建映射,直到处理完所有数据,然后将其存储在数据库表中。 Each subscriber has their own table that needs to be populate in some form with the data provided. 每个订户都有自己的表,该表需要以某种形式填充所提供的数据。 What I am trying to accomplish is distributing the list to the subscribers at the same time and once all subscribers are finished processing the next set off data is supplied and so forth until all the data has been processed for a date range. 我要完成的工作是同时将列表分发给订户,一旦所有订户都完成了处理,就提供下一个抵销数据,依此类推,直到在日期范围内处理完所有数据为止。
If anyone has some suggestions what I can look at, that would be awesome. 如果有人对我的建议有什么建议,那将很棒。
I'd start this way: 我将以这种方式开始:
Now, all this is a suggestion, with multiple other possible solutions, and a very high-level one at that with many implementation details left unsaid. 现在,所有这一切都是一个建议,并提出了其他多种可能的解决方案,而其中一个非常高级的建议是,其中未提及许多实现细节。 You should keep your eyes open as you work, and not be afraid to change routes if it is better. 您在工作时应该睁大眼睛,如果情况更好,不要害怕改变路线。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.