title: PipedWriter and PipedReader returningNullPointerException when using in different classes
body: <p>I'm using pipedwriter and pipedreader in java to read and write data from pipe, but i'm having issue, when i'm trying to use pipereader in another class it returns null pointer exception.Please check the below code, class RP is giving NullPointerException, when trying to read data from using PipedReader.read(); method</p>
  <pre><code> public static void main(String[] args)throws Exception {
          
          WP writer = new WP();
          RP reader = new RP();
          writer.start();
          writer.join();
          reader.start();
          reader.join();
      }
  }
  class WP extends Thread{
      PipedWriter pw;
      PipedReader pr;
      public void run(){
         try{
         pr = new PipedReader();
         pw = new PipedWriter();
         pw.connect(pr);
         pw.append(&quot;IUB&quot;);
      }catch(Exception E){System.err.println(&quot;Exception In Writer:&quot;+E);}
  }}
  class RP extends Thread{
       WP obj = new WP();
       PipedWriter pw;
      PipedReader pr;
      public void run(){   
                pr = obj.pr;
                pw = obj.pw;
          try{
              System.out.println(&quot;Reading Data Using PipedReader&quot;);
              int data = pr.read();
              if(data!=-1){
                  System.out.println(&quot;ASCI Value:&quot;+data+&quot; | &quot;+&quot;Char Representation:&quot;+(char)data);
              }     
              }catch (Exception E){E.printStackTrace();}
          
      }
  }
  </code></pre>