Is there any way to communicate between two classes within an application using InputStreams and OutputStreams?

0
Posted

Is there any way to communicate between two classes within an application using InputStreams and OutputStreams?

0

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 =

0

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