I/O 操作如何阻塞?

发布于 2024-08-27 10:39:33 字数 222 浏览 8 评论 0原文

我特别指的是 InputStream (Java SE) 及其实现。

阻塞是如何进行的?我有点担心他们使用“忙等待”机制,因为这会产生大量开销。我相信他们会用另一种方式,但我只是想确定一下。

I am specifically referring to InputStream (Java SE) and its implementations.

How is blocking performed? I'm a little worried that they use a "busy-waiting" mechanism, as it would produce a lot of overhead. I believe they do it another way, but I'm just asking to be certain.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

天冷不及心凉 2024-09-03 10:39:33

不,他们不使用忙等待。这取决于实现(这取决于您使用的输入流的类型),但通常它可能会使用阻塞操作系统级 API,因此效率将取决于操作系统。

No, they don't use busy-waiting. It's up to the implementation (which will depend on the kind of input stream you're using), but generally it's likely to use a blocking OS-level API, so the efficiency will depend on the OS.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文