您的位置:首页 > 编程语言 > Java开发

4 ways to do concurrency in Java: Threads, Executors, ForkJoin and Actors

2015-01-09 21:08 567 查看
4 ways to do concurrency in Java: Threads, Executors, ForkJoin and Actors (0 messages)

在Java中的四种并行方式:Threads, Executors, ForkJoin and Actors

• POSTED BY: Oleg Šelajev

来自:Oleg Šelajev

• POSTED ON: December 11 2014 08:01 EST

• 时间:2014/12/11

Humanity has come up with a number of solutions and models for concurrent computations that emphasize different parts of the problems, as well as making different choices for the computational tradeoffs that occur when
we talk about achieving parallelism.

人们为了强调并行计算不同部分的问题提出许多解决类和模型,我们在谈论关于实现并行时也要对计算发生的权衡做出不同的选择。

In this post we’ll go over the following methods and approaches to enable concurrent processing and asynchronous code in Java, we'l talk about benefits, drawbacks and the best use cases for:

在这里我们将重温下面的方法并且可以获得在Java中执行并行和异步的方法,我们将讨论其中的优点和缺点以及最佳的使用案例:

• Bare Threads

Bare Threads

• Executors & Services

Executors & Services

• ForkJoin framework and parallel streams

ForkJoin模式和并行流

• Actor model

Actor 模型

And to make things more interesting, we didn’t just provide any kind of code to illustrate the approach, but used a common task, so the code in every section is more or less equivalent to each other.

并且为了更有趣,我们不仅会提供各种类型的代码,也会使用通俗的作业,所以每个部分的代码都差不多是等价的。

Continue reading the full article on RebelLabs:
http://zeroturnaround.com/rebellabs/flavors-of-concurrency-in-java-threads-executors-forkjoin-and-actors/
阅读文章请戳:

http://zeroturnaround.com/rebellabs/flavors-of-concurrency-in-java-threads-executors-forkjoin-and-actors/
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐