After this commit, common functionality for threads are gathered in a base class.
Less code, removed AtomicBoolean since it can be replaced with a volatile boolean, eliminating an allocation
Some members are made final
Fix one condition where read returns a large negative integer instead of the correct byte value.
Fix a second condition where checkFromBuffer returns a negative number and triggers a serial read before the buffer is depleted.
For example, if 0xFE is read, 0xFFFFFFFE is returned from the buffer which is out of the byte range.