Import java. io. *; class Send implements Runnable {// Thread class private PipedOutputStream pos = null; // The public Send () {this. pos = new PipedOutputStream (); // instantiate the output stream} public void run () {String str = "Hello World !!! "; // Try {this. pos. write (str. getBytes ();} catch (IOException e) {e. printStackTrace ();} try {this. pos. close ();} catch (IOException e) {e. printStackTrace () ;}} public PipedOutputStream getPos () {// gets the output stream of this thread's pipeline return this. pos ;}}; class Receive implements Runnable {private PipedInputStream pis = null; // The public Receive () {this. pis = new PipedInputStream (); // instantiate input stream} public void run () {byte B [] = new byte [1024]; // receive content int len = 0; try {len = this. pis. read (B); // read content} catch (IOException e) {e. printStackTrace ();} try {this. pis. close (); // close} catch (IOException e) {e. printStackTrace ();} System. out. println ("received content:" + new String (B, 0, len);} public PipedInputStream getPis () {return this. pis ;}}; public class PipedDemo {public static void main (String args []) {Send s = new Send (); Receive r = new Receive (); try {s. getPos (). connect (r. getPis (); // connection pipe} catch (IOException e) {e. printStackTrace ();} new Thread (s ). start (); // start the Thread new Thread (r ). start (); // start thread }};