refactory the producer and consumer's constructor design.