开发者

FJTask vs Future+Callables+ExecutorService

开发者 https://www.devze.com 2023-01-13 09:46 出处:网络
Objective: to make someth开发者_如何学JAVAing like unpretentious map/reduce. There are many tasks they should be run in parallel, results added to the collection. If the task lasts longer than a certa

Objective: to make someth开发者_如何学JAVAing like unpretentious map/reduce. There are many tasks they should be run in parallel, results added to the collection. If the task lasts longer than a certain time (eg 3 seconds) - cancel it. Which way is faster and more convenient? Share your experiences in building a "correct" multi-threading. thx in advance.

FJTask https://docs.google.com/viewer?url=http://gee.cs.oswego.edu/dl/papers/fj.pdf


Take a look at ParallelArrayWithMapping. It is used in a ForkJoinPool (similar useage with FJTask). There is a method called reduce that may help you. Using a Fork Join Pool and the java 7 FJ Framework is very fast and offers nice exploitations of all available processors.

0

精彩评论

暂无评论...
验证码 换一张
取 消