I do not know how to prioritize tasks here. I know that cats should make birth first, kittens go out of basket and last is brining kittens back to basket. Problem is that I do not know how to use join to do that. I know that join makes a Thread wait for other thread to finish. Please let me know how it works. How let's say I have 4 threads: thread1 thread2 thread3 thread4 How can I set threads as list: 2,4,1,3 thread2.join; thread4.join; thread1.join; thread3.join; ??? I have resolved this task but I do not understand how it works. I thought that maybe if thread is in main method it is prioritized but when I did cat1.join and cat2.join second cat randomly gave birth first or let kittens from cat1 go out of basket