kurbatov / firmata4j

Firmata client written in Java.
MIT License
87 stars 45 forks source link

Properly stop firmata parser thread in FirmataParser.stop() #25

Closed centic9 closed 6 years ago

centic9 commented 6 years ago

When shutting down, sometimes the firmata-parser-thread is kept running because it never returns from the call to byteQueue.take(). In my case this causes an application to not stop because a non-daemon thread is still running.

A parserThread.interrupt() in stop() causes the take() to return with an InterruptedException and thus stops the thread correctly.

I also tried to add a unit-test for this, but the whole project is not set up for it, are you interested in a separate PR with a few unit-tests?

kurbatov commented 6 years ago

Thank you. It would be nice to have some unit-tests.