Added mutex loxking around the message queue.