UPDATE I’m solving a producer / consumer problem, and I want to create a few producers and consumers (several threads) and I have a question how can I create several threads correctly so that one task is not performed by two threads (each thread does a different task). code: I tried to do it just in a loop like here: