Works with producers consumers in single threads.