Implement multiple threads

Implement Producer and Consumer threads and add some tests.