How to delay somthing without stopping the gameloop?

Hi!
I’m trying to delay something in my game and the only thing I found in the internet is Thread.sleep but the problem is that it stops my gameloop.
I also tryed this:


		while(alive == false) {
			timer ++;
			if(timer > 10){
				handler.NextLevel();
				timer = 0;
			}
			

and it freezed the game.
What is the right way to do it? thanks!