Loading [MathJax]/jax/output/CommonHTML/config.js
前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >专栏 >Callable和Supplier的区别

Callable和Supplier的区别

作者头像
xiaoxi666
发布于 2019-07-24 07:13:14
发布于 2019-07-24 07:13:14
1.2K0
举报
文章被收录于专栏:xiaoxi666的专栏xiaoxi666的专栏

Callable is "A task that returns a result, while a Supplier is "a supplier of results". In other words a Callable is a way to reference a yet-unrun unit of work, while a Supplier is a way to reference a yet-unknown value.

It's possible that a Callable could do very little work and simply return a value. It's also possible a Supplier could do quite a lot of work (e.g. construct a large data structure). But generally speaking what you care about with either is their principle purpose. For example an ExecutorService works with Callables, because it's primary purpose is to execute units of work. A lazy-loaded data store would use a Supplier, because it cares about being supplied a value, without much concern about how much work that might take.

Another way of phrasing the distinction is that a Callable may have side-effects (e.g. writing to a file), while a Supplier should generally be side-effect free. The documentation doesn't explicitly mention this (since it's not a requirement), but I'd suggest thinking in those terms. If the work is idempotent use a Supplier, if not use a Callable.

摘自https://softwareengineering.stackexchange.com/questions/254311/what-is-the-difference-between-callablet-and-java-8s-suppliert

本文参与 腾讯云自媒体同步曝光计划,分享自作者个人站点/博客。
原始发表:2019-07-22 ,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体同步曝光计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
暂无评论
推荐阅读
编辑精选文章
换一批
研发:What is a DDoS Attack?
A distributed denial-of-service (DDoS) attack is a malicious attempt to disrupt normal traffic of a targeted server, service or network by overwhelming the target or its surrounding infrastructure with a flood of Internet traffic. DDoS attacks achieve effectiveness by utilizing multiple compromised computer systems as sources of attack traffic. Exploited machines can include computers and other networked resources such as IoT devices. From a high level, a DDoS attack is like a traffic jam clogging up with highway, preventing regular traffic from arriving at its desired destination.
heidsoft
2018/10/18
6430
研发:What is a DDoS Attack?
【Fiber】:[译]深入解析React的新协调算法
深入研究 React 的新架构 Fiber,了解新协调算法的两个主要阶段。我们将详细了解 React 如何更新组件状态(state)、属性(props)以及如何处理子元素(children)。
WEBJ2EE
2021/02/26
6700
【Fiber】:[译]深入解析React的新协调算法
Effective Java 2.0_中英文对照_Item 6
文章作者:Tyan 博客:noahsnail.com  |  CSDN  |  简书
Tyan
2022/05/09
3000
Is it worth learning JavaScript in 2020?
Is-it-worth-learning-JavaScript-in-2020_-2.png
用户4822892
2020/02/11
4790
Is it worth learning JavaScript in 2020?
Structured Concurrency 发布于
Structured Concurrency is avaiable as an incubator API in the JDK 19. This is still about Project Loom, probably one of the most anticipated features of the JDK 19.
DioxideCN
2023/10/21
2550
Structured Concurrency
                        
                            发布于
React源码学习进阶(七)挂载阶段的commitWork
首先我们回顾一下挂载开始的入口performSyncWorkOnRoot,它位于packages/react-reconciler/src/ReactFiberWorkLoop.js:
孟健
2022/12/19
8340
React源码学习进阶(七)挂载阶段的commitWork
7、常见面试口语提问问题汇总
Good morning! It is really my honor to have this opportunity for an interview; I hope I can make a good performance today. I’m confident that I can succeed. Now I will introduce myself briefly I am 24 years old, born in Hubei province. I graduated from Hubei Automotive Industries Institute. My major is software engineering, and I got my bachelor degree after my graduation in the year of 2009. I spend most of my time on study, I have passed CET6, and I have acquired basic knowledge of my major during my school time. In July 2009, I begin working for a state-owned technology company as a software development engineer in wuhan. Because I want to change my working environment, I’d like to find a job which is more challenging. Moreover HP is a global company, so I feel I can gain the most from working in this kind of company environment. That is the reason why I come here to compete for this position. I think I’m a good team player and I’m a person of great honesty to others. Also I am able to work under great pressure. That’s all. Thank you for giving me the chance.
全栈程序员站长
2022/07/31
4150
【Fiber】:[转]深度解析 React 内部 state、props 的更新过程
In my previous article Inside Fiber: in-depth overview of the new reconciliation algorithm in React I laid the foundation required to understand the technical details of the update process that I’ll describe in this article.
WEBJ2EE
2021/02/26
7340
【Fiber】:[转]深度解析 React 内部 state、props 的更新过程
Go is not (very) simple, folks
I’ve recently started coding a little bit in Go, mostly out of curiosity. I’d known quite a bit about it beforehand, but never tried it out in practice (there was no need). But now Go is being considered as one of the options for a project in the team where I work and so I thought it would be nice to get a bit of hands on experience.
李海彬
2018/12/21
4810
Go is not (very) simple, folks
是的,开源真的很酷
最近某事件沸沸扬扬,我不小心参与进issue好心提醒它们关闭无关话题,但不幸的是,遭到了邮件骚扰(好吧,其实是我不知道怎么取消issue的邮件推送:(
姓王者
2025/02/28
621
Voice Liveness Challenge
While use of an active challenge/response paradigm to confirm liveness of the subject in a biometric authentication system can greatly strengthen security, it also carries with it an added burden on the user. Requesting the user to perform specific extra actions can increase the time to authenticate, increases the likelihood of user error, and can lead to missed detections.
用户6026865
2022/09/02
2770
Voice Liveness Challenge
【Hooks】:[组]How to useReducer in React
The concept of a Reducer became popular in JavaScript with the rise of Redux as state management solution for React. But no worries, you don't need to learn Redux to understand Reducers. Basically reducers are there to manage state in an application. For instance, if a user writes something in an HTML input field, the application has to manage this UI state (e.g. controlled components).
WEBJ2EE
2021/02/26
3310
【Hooks】:[组]How to useReducer in React
A Novel Proof-of-Reputation Consensus for Storage Allocation in Edge Blockchain Systems 精读笔记(一)
摘要——边缘计算指导协同工作具有不同传感、存储和计算资源。例如,传感器节点收集数据并然后将其存储在存储节点中,以便计算节点可以访问需要时提供数据。在本文中,我们关注的是质量边缘网络存储分配中的服务(QoS)。我们设计了一个边缘网络中节点的信誉机制,这使得交互节点评估服务质量以供参考。每个节点公开广播个人信誉列表给评估所有其他节点,每个节点都可以计算全局通过聚合个人声誉来获得所有节点的声誉。然后我们提出了一种存储分配算法,能将数据存在适当的位置。该算法考虑了公平性,效率和可靠性源于声誉。我们建立一个新颖的信誉证明(PoR)区块链来支持关于信誉机制和存储分配的共识。PoR区块链确保安全性能,节省计算资源,避免中心化。广泛的模拟结果表明我们提出的算法是公平、高效和可靠的。这结果还表明,在存在攻击者的情况下,成功诚实节点访问数据率可达99.9%。
timerring
2022/07/20
5910
Linux 内核编码风格
像其他大型软件一样,Linux制订了一套编码风格,对代码的格式、风格和布局做出了规定。我写这篇的目的也就是希望大家能够从中借鉴,有利于大家提高编程效率。
用户7678152
2020/08/26
2.9K0
How to Grow Your Career as a JavaScript Developer?
JavaScript is one of the most beloved and desirable programming languages to learn in 2019. JS development is a hot career option in the programming world. It is one of the best-paying programming languages to get familiar with. It was developed by Brendan Eich back in 1995. Officially, the popular programming language is known as the ECMAScript.
用户4095052
2019/01/09
7270
How to Grow Your Career as a JavaScript Developer?
Node.js Backend Development: Features, Benefits
Node.js backend development has become extremely popular among software developers. In order to keep up with modern technologies, it is necessary to know what is Node.js, what are the reasons to use it, where to hire developers, etc. Answers to these questions will be discovered in this article.
用户8617680
2021/05/27
9610
Node.js Backend Development: Features, Benefits
Python & Async Simplified
As some of you may be aware, I have spent many of the last months rewriting Channels to be entirely based on Python 3 and its asynchronous features (asyncio).
heidsoft
2022/01/11
4270
Python & Async Simplified
C++ Dos and Don'ts
转自:https://chromium.googlesource.com/chromium/src/+/HEAD/styleguide/c++/c++-dos-and-donts.md
望天
2020/12/08
8970
[Repost]A Survival Guide to a PhD
This guide is patterned after my “Doing well in your courses”, a post I wrote a long time ago on some of the tips/tricks I’ve developed during my undergrad. I’ve received nice comments about that guide, so in the same spirit, now that my PhD has come to an
昊楠Hacking
2018/03/08
1.1K0
[Repost]A Survival Guide to a PhD
SRS: Load Balancing Streaming Servers
Load Balancing Streaming Servers Written by Winlin[1], Azusachino[2], Benjamin 程序员确实应该要能看英文和写英文,支持陶老板说的《要做研发高手,就是必须能看英文、写英文》,所以写了一篇试试。大家先试试看看吧,看看能不能看懂,搞不好大家都能看懂;万一看不懂,我们会再翻译成中文;请评论区留言哦。 When our business workloads exceed streaming-server capacity, we have
Winlin
2022/05/17
7770
SRS: Load Balancing Streaming Servers
相关推荐
研发:What is a DDoS Attack?
更多 >
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档