I think the problem is you have the two things running in parallel, so they are creating at the same time without checking to see what the other is doing. There could also be a problem with the function itself not checking if there is already something created at that point. What you could do is create an array of Boolean values and update that to show that something is already in the random position selected, then just do an if statement to check and see if something is there or not. If there is something already there (i.e. the Boolean value is true), then pick another random number.
@mcmelord: Go
I think the problem is you have the two things running in parallel, so they are creating at the same time without checking to see what the other is doing. There could also be a problem with the function itself not checking if there is already something created at that point. What you could do is create an array of Boolean values and update that to show that something is already in the random position selected, then just do an if statement to check and see if something is there or not. If there is something already there (i.e. the Boolean value is true), then pick another random number.