- iOS/Objective-C 元类和类别
- objective-c - -1001 错误,当 NSURLSession 通过 httpproxy 和/etc/hosts
- java - 使用网络类获取 url 地址
- ios - 推送通知中不播放声音
我在 SO 上看到了两个答案,它们声称 Java 提供的 PipedInputStream
和 PipedOutputStream
类存在缺陷。但他们没有详细说明他们出了什么问题。他们真的有缺陷吗?如果有的话是什么?我目前正在编写一些使用它们的代码,所以我想知道我是否走错了路。
PipedInputStream
andPipedOutputStream
are broken (with regards to threading). They assume each instance is bound to a particular thread. This is bizarre.
对我来说,这既不奇怪也不坏。也许作者还有其他一些缺陷?
In practice they are best avoided. I've used them once in 13 years and I wish I hadn't.
但是那个作者想不起来是什么问题了。
对于所有类,尤其是在多线程中使用的类,如果误用它们就会出现问题。所以我不考虑不可预知的"write end dead" IOException
PipedInputStream
可能会抛出一个缺陷(未能 close()
连接的 PipedOutputStream
是一个错误;请参阅文章 Whats this? IOException: Write end dead,作者: Daniel Ferbers,了解更多信息)。还有哪些其他声称的缺陷?
最佳答案
它们没有缺陷。
对于所有类,尤其是在多线程中使用的类,如果误用它们就会出现问题。 PipedInputStream
可能抛出的不可预测的“写入结束死机”IOException
不是缺陷(无法close()
连接的PipedOutputStream
是一个错误;有关更多信息,请参阅 Daniel Ferbers 的文章 Whats this? IOException: Write end dead。
关于java - PipedInputStream/PipedOutputStream 的缺陷,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9483833/
我有一个与 PipedInputStream 相关的问题和 PipedOutputStream ,也不知道是我对这些类的设计有误解,还是PipedInputStream.java中的java代码有bu
我正在使用java管道将数据(outstream)从解压模块(JavaUncompress类)传递到解析模块(处理类),文件很大,我想先解压文件并直接解析而不是保存解压缩的文件,然后解析。但是,它仅适
我正在学习 java PipedInputStream/PipeOutputStream 。 我想读取标准输入(下面的“Source”类)并将其重定向到一个进程(此处为“grep A”),Grep 的
我在 SO 上看到了两个答案,它们声称 Java 提供的 PipedInputStream 和 PipedOutputStream 类存在缺陷。但他们没有详细说明他们出了什么问题。他们真的有缺陷吗?如
我正在尝试编写一段解锁代码来读取 PipedInputStream .它基本上会在调用阻塞读取 API 之前检查是否有任何内容要读取: int n = 0; if ((n = pipedInputSt
PipedInputStream 如何从 PipedOutputStream 读取数据?是使用toString()还是有一些隐藏的魔法来访问private成员变量? 最佳答案 PipedOutputS
我正在编写一个程序,该程序通过使用 Class 和 Method 类调用 main 方法来执行另一个 Java 程序。然后,另一个程序尝试从 System.in 读取。为了将参数传递给程序,我将 Sy
什么是管道流的用例?为什么不将数据读入缓冲区然后将它们写出呢? 最佳答案 BlockingQueue 或类似的集合可能会更好地为您服务,它们是线程安全的、健壮的并且扩展性更好。 关于java - Pi
Write end dead exception在以下情况发生:两个线程: A: PipedOutputStream put = new PipedOutputStream(); String
我正在编写一个简单的 Swing GUI,其中包含一个用于打印调试消息和异常的文本字段。我目前在写入 PipedOutputStream 的地方设置了它,并且我有一个守护线程,它从连接的 PipedI
我有一个需要读取的 OutputStream,因此我使用以下 (Groovy) 代码来获取对数据的 InputStream 引用: PipedInputStream inputStream = new
我有一个数据生成器,它在单独的线程中运行并将生成的数据推送到连接到 PipedInputStream 的 PipedOutputStream 中。此输入流的引用通过公共(public) API 公开,
PipedOutputStream的Android实现 write(byte[] buffer, int offset, int count) 是根据write(byte oneByte)实现的。更具
我有一个具有单读者线程模型的多写入线程。ThreadMultipleDateReceiver 类设计用于从多个线程读取。 public class ThreadMultipleDateReceiver
我在 Scala 中有以下代码: val pos = new PipedOutputStream() val pis = new PipedInputStream(pos)
如何正确完成管道输出端的工作?我需要写入线程终止或做一些其他工作,而读取线程读取所有写入数据直到结束。 我应该在写入端关闭管道还是什么? 更新 1 我想澄清一下......根据给定的答案,我认为设计管
我想使用 PipedOutputStream 和 PipedInputStream Java 类编写类似于Producer Consumer Problem 的示例。 注意:这是应用其原理的小示例。
很难说出这里要问什么。这个问题模棱两可、含糊不清、不完整、过于宽泛或夸夸其谈,无法以目前的形式得到合理的回答。如需帮助澄清此问题以便重新打开,visit the help center . 关闭10
我不确定,但我很确定我在 Oracle Java 实现(1.7.0_67 和 1.8.0_31 我可以确认受影响)中发现了一个错误(或未记录的功能)。 症状 当管道已满时,写入管道的时间可能比管道再次
我最近发现了这个成语,我想知道我是否遗漏了什么。我从未见过它使用过。我在野外使用过的几乎所有 Java 代码都倾向于将数据放入字符串或缓冲区中,而不是像这个示例(例如使用 HttpClient 和 X
我是一名优秀的程序员,十分优秀!