Hi
I have an issue ,trying to build a unique number generator.
Specifiacally, the generator is this
Code:
                Random randomPerson=new Random(System.nanoTime());
		int no_persons=persons.length;
		
		int cnt=0;
		while(cnt<70) {
			int person=randomPerson.nextInt(no_persons);
			if(function()) {
				cnt++;}
function() returns a boolean whether the random number hasn't used before (and some other operations eg insertion to an array)
When this program is executed, I either take the aprropriate output, or the program stucks (infinite loop). Is there any possibility to fix this infinite loop?

Thanks in advace!