Java multi-threading: How to prevent simultaneous reproduction logic between two threads?
I have created a Fish class that simulates a fish that reproduces in a Java program. Each fish must breed by meeting another random fish. But the problem is that two fish find each other as a pair and create two children at the same time. This process of reproduction is repeated several times at the same time.