The constructor for the ModbusSerialListener class contains a call to the listen() method, which does not return until the listen() method completes. The is inconsistent with the Java programming model, where a class constructor returns the object, which is then acted upon by its methods.
The solution (IMHO) is to make the listener() method public and add a second constructor with a different signature. A better solution (IMHO) is to change the name to run() and have ModbusSerialListener extend Runnable so the listener can be executed as a Thread().
Log in to post a comment.