Java 并发、Akka 和 RxJava 之间的区别?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/27525849/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Difference between Java Concurrency, Akka and RxJava?
提问by Harmeet Singh Taara
Today I found that, for concurrency in java we have good framework like Akka
and I also found that, there is a reactive programming frameworks like RxJava
for performing multithreading
in application. But I'm still confused! Why are both better than Java Concurrency
framework?
今天我发现,对于 Java 中的并发,我们有很好的框架,例如Akka
,我还发现,有一个响应式编程框架,例如RxJava
用于multithreading
在应用程序中执行。但我还是一头雾水!为什么两者都优于Java Concurrency
框架?
Nowadays reactive programing is mature topic, and most languages have support for Functional Reactive Programing
like Netflix
provide APIs regarding Reactive programming
for more than one language. Rxjava
is one of the api that is used for java
, scala
etc. According to RxJava
, they internally use actors for maintaining multithreading
and Akka
also uses Actors
for multithreading
programming.
现在反应式编程是一个成熟的话题,大多数语言都支持Functional Reactive Programing
像Netflix
提供关于Reactive programming
不止一种语言的API 。Rxjava
是用于API之一java
,scala
等等。根据RxJava
他们内部使用演员为维护multithreading
和Akka
也使用Actors
了multithreading
编程。
So, what is the difference between Akka
and Reactive Programming
approach and why they are good from Java Concurrency
?
那么,Akka
和Reactive Programming
方法之间有什么区别,为什么它们是好的Java Concurrency
?
采纳答案by Joost de Vries
According to Mathias Doenitz at this point in time RxJava doesn't have back pressure unlike Akkas Reactive Streams implementation. But RxJava seems to be working on adding back pressure.
根据 Mathias Doenitz 的说法,此时 RxJava 没有与 Akkas Reactive Streams 实现不同的背压。但 RxJava 似乎正在努力增加背压。
Both frameworks will be able to interact through the reactive streaming spi. So you will be able to do very very similar things. According to Mathias the difference will be that the Akka implementation is based internally on actors, not on multi-threading. And as a result will be more performant.
两个框架都将能够通过反应式流媒体 spi 进行交互。所以你将能够做非常非常相似的事情。根据 Mathias 的说法,不同之处在于 Akka 的实现在内部基于 actor,而不是基于多线程。因此,性能会更高。
My source for this information is a talkthat Mathias gave last week at the Dutch Scala user group.
我的信息来源是Mathias 上周在荷兰 Scala 用户组上的一次演讲。
edit: I stand corrected wrt back pressure support in RxJava. If you follow Eriks link you can read what back pressure means.
编辑:我在 RxJava 中纠正了 wrt 背压支持。如果您点击 Eriks 链接,您可以阅读背压的含义。
回答by denis631
Akka Streams being based on actors provides interop between actors and streams, e.g.:
Akka Streams 基于演员提供演员和流之间的互操作,例如:
- reading from actor and passing it to streams and
- reading from streams and passing it to actors
- 从演员读取并将其传递给流和
- 从流中读取并将其传递给演员