title: java rxtx SerialWriter issue
body: <p>I am using RXTX to communicate between JAVA and a microcontroller.</p>
  
  <p>This is the JAVA code for opening a connection, sending and receiving data</p>
  
  <pre><code>package app;
  
  import gnu.io.CommPort;
  import gnu.io.CommPortIdentifier;
  import gnu.io.SerialPort;
  
  import java.io.IOException;
  import java.io.InputStream;
  import java.io.OutputStream;
  
  public class SerialCommunication1 {
      private static SerialCommunication1 instance = null;
      private static boolean coonected = false;
  
      public static SerialCommunication1 getInstance(){
          if(instance == null)
              instance = new SerialCommunication1();
          return instance;
      }
  
      private SerialCommunication1() {
          super();
          try {
              connect("COM4");
          } catch (Exception e) {
              // TODO Auto-generated catch block
              e.printStackTrace();
          }
          SerialCommunication1.coonected = true;
      }
  
      void connect(String portName) throws Exception {
          CommPortIdentifier portIdentifier = CommPortIdentifier
                  .getPortIdentifier(portName);
          if (portIdentifier.isCurrentlyOwned()) {
              System.out.println("Error: Port is currently in use");
          } else {
              CommPort commPort = portIdentifier.open(this.getClass().getName(),
                      2000);
  
              if (commPort instanceof SerialPort) {
                  SerialPort serialPort = (SerialPort) commPort;
                  serialPort.setSerialPortParams(9600, SerialPort.DATABITS_8,
                          SerialPort.STOPBITS_2, SerialPort.PARITY_NONE);
  
                  InputStream in = serialPort.getInputStream();
                  OutputStream out = serialPort.getOutputStream();
  
                  (new Thread(new SerialReader(in))).start();
                  (new Thread(new SerialWriter(out))).start();
  
              } else {
                  System.out
                          .println("Error: Only serial ports are handled by this example.");
              }
          }
      }
  
      /** */
      public static class SerialReader implements Runnable {
          InputStream in;
  
          public SerialReader(InputStream in) {
              this.in = in;
          }
  
          public void run() {
              byte[] buffer = new byte[1024];
              int len = -1;
              try {
                  while ((len = this.in.read(buffer)) &gt; -1) {
                      System.out.print(new String(buffer, 0, len));
                  }
              } catch (IOException e) {
                  e.printStackTrace();
              }
          }
      }
  
      /** */
      public static class SerialWriter implements Runnable {
          OutputStream out;
          static String str = null;
  
          public SerialWriter(OutputStream out) {
              this.out = out;
          }
  
          public void run() {
              System.out.println("Will try to execute");
              try {
                  if(str.length() &gt; 0){
                      this.out.write(str.getBytes());
                      str = null;
                  }
              } catch (IOException e) {
                  e.printStackTrace();
              }
          }
      }
  
  }
  </code></pre>
  
  <p>And this is the Java code that is calling when an event triggers</p>
  
  <pre><code>SerialCommunication1.getInstance();
  if(ledStatus == true) {SerialCommunication1.SerialWriter.str = "4A01";}
  else {SerialCommunication1.SerialWriter.str = "4A00";}
  stopProcess();
  </code></pre>
  
  <p>And now the problem. I need to send a command to my microcontroller with the code 4A01 and, after receiving the answer, I need to call it again with the code 4A00. The calls are triggered by a button from my Java interface. The problem is that the second call is not executed (4A00 is not sending). I tried to inverse the command codes and they work well. After the first one (4A01) is executed, my microcontroller reacts and sends the response which is read by java and my interface is updated. When I send the invers command (4A00) it stops exactly at this line <code>SerialCommunication1.SerialWriter.str = "4A00";</code> and doesn't even enter inside the SerialWriter's run() method.</p>
  
  <p>Do you have any idea why is this happening? From the side of my microcontroller there is no problem, I checked all the possibilities with a tool.</p>
  
  <p>I hope I made myself clear.</p>
  
  <p>Thank you!</p>
  
  <p>LE: I forgot to tel you that it didn't throw any errors or exceptions</p>