0

I'm doing with parallel programming project. The requirement is to search a list of string in a lattice of cube (3D-dimension and maximum is 1000 elements). The max size of list is 1000 and the max length of string is 100.

I create 3 ForkTask: search in X-Dimension(NxN 2D-array), in Y-Dimension(NxN 2D-array), in Z-Dimension(NxN 2D-array). For each Task, I start searching the string in 2D-array and I create a ForkTask for this. I had a function to search a string in 2D-array.

I see that I have a lot of ForkTask as well as thread. To improve the search performance and time reduction, I check that if a task.join() is true, I will cancel the rest of tasks.

Is it a wise approach? Anyone can give me any recommendation or suggestion or advice?

Thanks

4

1 回答 1

0

确定您的项目中的工作是什么。比方说,在一维中搜索是一项工作。将您的作业实现为可运行文件并在 Executor 中执行它们。http://docs.oracle.com/javase/6/docs/api/java/util/concurrent/Executor.html 如果有超过 3 个核心,您还可以为每个维度的每个切片使用一个作业。如果您的作业非常快(低于 10µs),则作业队列的开销可能太大。

于 2013-11-28T19:58:33.660 回答