Is there any way to communicate between two classes within an application using InputStreams and OutputStreams?
Location: http://www.jguru.com/faq/view.jsp?EID=54012 Created: May 22, 2000 Modified: 2000-05-23 18:28:32.671 Author: John Zukowski (http://www.jguru.com/guru/viewbio.jsp?EID=7) Question originally posed by Sean Wiechman (http://www.jguru.com/guru/viewbio.jsp?EID=53867 The PipedInputStream/PipedReader and PipedOutputStream/PipedWriter streams provide synchronized I/O across threads, from within one class or multiple classes. The following example demonstrates their usage and was taken from my Mastering Java 2 book: import java.io.*; public class PipeTest { public static void main (String args[]) { new OilRefinery(); try { // delay arrival Thread.currentThread().sleep(500); } catch (InterruptedException e) { } new SuperTanker(); } // This class consists of a Thread that can accept “pipline” hook-ups // via the “clickClunk” method. Clients have to find us though from // our Thread name “ThePipeTerminal” static class OilRefinery extends Thread { static final int EOF = -1; boolean alone =
Location: http://www.jguru.com/faq/view.jsp?EID=54012 Created: May 22, 2000 Modified: 2000-05-23 18:28:32.671 Author: John Zukowski (http://www.jguru.com/guru/viewbio.jsp?EID=7) Question originally posed by Sean Wiechman (http://www.jguru.com/guru/viewbio.jsp?EID=53867 The PipedInputStream/PipedReader and PipedOutputStream/PipedWriter streams provide synchronized I/O across threads, from within one class or multiple classes. The following example demonstrates their usage and was taken from my Mastering Java 2 book: import java.io.*; public class PipeTest { public static void main (String args[]) { new OilRefinery(); try { // delay arrival Thread.currentThread().sleep(500); } catch (InterruptedException e) { } new SuperTanker(); } // This class consists of a Thread that can accept “pipline” hook-ups // via the “clickClunk” method. Clients have to find us though from // our Thread name “ThePipeTerminal” static class OilRefinery extends Thread { static final int EOF = -1; boolean alone =
Related Questions
- I have previously taken classes at Johns Hopkins University (JHU). Does this change my application requirements for SAIS Summer Programs?
- Can a standalone OHS based on Apache 2.0 communicate with an existing Oracle Application Server 10g Release 3 (10.1.3) instance?
- Is there any way to communicate between two classes within an application using InputStreams and OutputStreams?