multithreaded consumer/producer implementation