Implemented multiple threads to handle different type of messages.