title: Java HIDAPI - Asynchronous reading
body: <p>Sort of a follow up to <a href="https://stackoverflow.com/questions/23796353/java-and-hid-communication/23798108#23798108">this</a> question, which I have now had a measure of success with (the LED turns on and off, hooray!), I now have another question.</p>
  
  <p>Besides writing to the device, I also have a need to read from the device.
  I would prefer NOT to have a thread sit there and query the device every 50 MS (considering the setting in which this device will be employed that's probably the only way to get this to work without whatever the Java equivalent of .Net Events are).</p>
  
  <p>Is there a way to set up a Java "event" (term used loosely) that will fire when there are bytes waiting to be read from the device?</p>
  
  <p>What I have now to write to the device is a terminal interface that accepts strings and responds to them by writing a byte array (or terminating):</p>
  
  <pre><code>    BufferedReader BR = new BufferedReader(new InputStreamReader(System.in));
      byte[] bBuffer = new byte[6];
      String cmd = BR.readLine();
      while (true){
          switch(cmd){
              case "ON":
                  dev.write(ON);
                  Thread.sleep(READ_UPDATE_DELAY_MS);
                  dev.read(bBuffer);
                  break;
              case "OFF":
                  dev.write(OFF);
                  Thread.sleep(READ_UPDATE_DELAY_MS);
                  dev.read(bBuffer);
                  break;
              case "EXIT":
                  System.exit(0);
          }           
          cmd = BR.readLine();
      }
  </code></pre>
  
  <p>What I was hoping for was something like:</p>
  
  <pre><code>dev.InputReceived = &lt;some input handling function&gt;;
  </code></pre>
  
  <p>Is this possible?</p>