add 2 variable to keep track of number of message read/writen
avoid using lock