Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我特别指的是InputStream (Java SE)及其实现。
阻塞是如何执行的?我有点担心他们使用“忙等待”机制,因为它会产生很多开销。我相信他们会以另一种方式做到这一点,但我只是想确定一下。
不,他们不使用忙等待。这取决于实现(这取决于您使用的输入流的类型),但通常它可能使用阻塞的操作系统级 API,因此效率将取决于操作系统。