uses locking rather than spawning a new thread every time it sends data