Re-implement synchronization

The serialEvent method can be called from the context of another thread (see SerialPort.addEventListener()). Use synchronize blocks to manage concurrent access.