title: Pass parameter to processbuilder outputstream in different class
body: <p>I am just trying to control processbuilder inputstream and outputstream from different class</p>
  
  <p>It is main class</p>
  
  <pre><code>public class Controller
  {
      public static void main(String[]args)
      {
          Runner r=new Runner("Test");
          r.activateInput();
          r.setInput("Test");
      }
  }
  </code></pre>
  
  <p>It is other class to run process</p>
  
  <pre><code>import java.io.*;
  public class Runner
  {
      boolean activeInput=true;
      boolean active=true;
      String input;
      public Runner(String command)
      {
          try {
           // create a new process
           System.out.println("Creating Process...");
  
           ProcessBuilder compile = new ProcessBuilder("java","TestOut");
           compile.directory(new File("C:/Users/abhishek221192/Documents/Socket"));
           Process process = compile.start();
  
           OutputStream stdin = process.getOutputStream ();
           InputStream stderr = process.getErrorStream ();
           InputStream stdout = process.getInputStream ();
  
           final BufferedReader reader = new BufferedReader (new InputStreamReader(stdout));
  
           BufferedReader error = new BufferedReader (new InputStreamReader(stderr));
           final BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(stdin));
  
           //final Scanner scan=new Scanner(System.in);
  
             Thread T=new Thread(new Runnable() {
  
              @Override
              public void run() {
                  while(active)
                  {
                      if(activeInput)
                      System.out.println(activeInput+"  "+input);
                      String data ="Abhi";
                      data += "\n";
                      try {
                          if(activeInput){
                          writer.write(data);
                          writer.flush();
                          activeInput=false; 
                        }
                          //
                      } catch (IOException e) {
                          // TODO Auto-generated catch block
                          e.printStackTrace();
                      }
  
                  }
  
              }
          } );
          T.start();
          T.setName("Input");
              Thread T1=new Thread(new Runnable() {
  
              @Override
              public void run() {
             String line;
           try{
             while ((line = reader.readLine ()) != null) {
                   System.out.println(line);
              }} catch (IOException e) {
                          // TODO Auto-generated catch block
                          e.printStackTrace();
                      }
          }
              } );
          T1.start();
          T1.setName("Output");
  
           /*   
             String line;
              while ((line = error.readLine ()) != null) {
                   System.out.println(line);
              }
              */
              //stdout.close();
  
              //error.close();
  
             //T.stop();
             //stdin.close();
             //System.err.println("stdin closed");
             active=false;
           // close the output stream
           System.out.println("Closing the output stream...");
  
           //testProcessBuilder();
  
        } catch (Exception ex) {
           System.out.println("Error"+ex.getMessage());
  
  
        }
      }
      public void activateInput()
      {
          this.activeInput=true;
          System.out.println("active"+activeInput);
      }
      public void setInput(String input)
      {
          this.input=input;
      }
  
  }
  </code></pre>
  
  <p>It is TestOut code it include only one input statement</p>
  
  <p>TestOut.java</p>
  
  <pre><code>import java.util.*;
  public class TestOut
  {
     public static void main(String[]args)
     {
        Scanner sc=new Scanner(System.in);
        System.out.println("Output hello TestOut");
        System.out.println("Output1 "+sc.nextLine());
     }
  }
  </code></pre>
  
  <p>I am geting this output</p>
  
  <pre><code>Creating Process...
  true  null
  Closing the output stream...
  activetrue
  Output hello TestOut
  Output1 Abhi
  </code></pre>
  
  <p><code>r.setInput();</code> is not setting value</p>