Added mutex3 to 2nd solution to guarantee that a writer once arrived ,
will not be made to wait long.