开发者

Is there JDK interface which looks like interface ConsumerInterface<T> { void consume(T data); }

开发者 https://www.devze.com 2023-01-21 20:27 出处:网络
There\'s Callable<V> in JDK which is producer in开发者_开发知识库terface, is there consumer interface in JDK?

There's Callable<V> in JDK which is producer in开发者_开发知识库terface, is there consumer interface in JDK?

Question rationale: I'm writing executor which accepts 2-phase tasks: 1st phase is producing data, 2nd phase is consuming of that data. In between these 2 phases I could like to cancel task (i.e., to not performing consumption).

UPDATE: Well, I thought such general-purpose interface (e.g., useful in multi-threaded programming) could be in JDK. I just can't remember if I actually seen such interface in JDK.


I settled by writing my own interface.

0

精彩评论

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

关注公众号