Added 0.01 second sleep in the read thread. Also added more break to the write thread to make sure that the while loop is broken when the signal to shut down the thread is received.