Simulates a circular buffer with producers and consumers running simultaneously in threads