Fix thread bug.
Use queue to decouple message producers/consumer.