[英]Parallel processing of List in java
I have a list of objects with list size of 500K. 我有一个对象列表,列表大小为500K。 Each object in the list have a unique identifier.
列表中的每个对象都有一个唯一的标识符。 I want to validate the list for any duplicate objects(having the same identifier) and mark them with a flag.
我想验证任何重复的对象(具有相同的标识符)的列表,并用一个标志标记它们。 Since there are lot of elements in the list, the processing takes quite long time and i am not able to achieve within allotted time frame.
由于列表中有很多元素,因此处理需要相当长的时间,而且我无法在分配的时间范围内实现。
Is there any way to process the list in parallel(Using java Future/Callable)? 有什么方法可以并行处理列表(使用java Future / Callable)?
Thanks in advance. 提前致谢。 Mayuran
Mayuran
I don't know what your definition of a long time is, but 500K object is not a lot. 我不知道您对长时间的定义是什么,但是500K对象并不多。 Most likely your algorithm is quite inefficient.
您的算法很可能效率很低。 Rather than relying on parallelisation (how would you parallelise this anyway?), consider using a better data structure/algorithm for this.
与其依赖并行化(无论如何将其并行化?),不如考虑为此使用更好的数据结构/算法。
HashMap
or HashSet
should work quite well for this. HashMap
或HashSet
应该可以很好地工作。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.