Flow API 是否替换了 Observer 和 Observable

Is Flow API replacing Observer and Observable

在Java9中Flow API replace Observer and Observable?如果不是,那是什么?

The new Flow API is designed as a common denominator for reactive stream 像 RxJava 和 Reactive X 这样的库。在 Java 9 的基础上,它们可以让它们的类型扩展新的接口(或者这样想)。虽然在 JDK 中使用 API 当然很迷人,但在 Java 9 中并非如此,并且没有具体的计划来引入它(据我所知).

关于 ObserverObservable the issue which triggered the deprecation 状态:

Application developers should consider using java.beans for a richer change notification model. Or they should consider constructs in java.util.concurrent such as queues or semaphores to pass messages among threads, with reliable ordering and synchronization properties.

这些是针对应用程序开发人员编写新代码的建议。它没有提供有关更新现有代码或在 JDK 中做什么的建议。我想这是因为这两种情况都应该保持原样。

请注意,Java 并不一定使用 @Deprecated 表示 "will be removed"。相反,它也可以表示 "use better alternatives",我认为这里就是这种情况。所以用几句话回答你的问题:

In Java 9 does Flow API replace Observer and Observable

没有

and if it doesn't what does.

没有。