How to make temporarily invincible player? [Solved]

Alright so I have a game where you try to dodge obstacles and stuff. Now whenever I have my player collide I want the player to be temporarily invincible. I have the collision set up already and that works perfectly, but its in a loop and so I have no idea how to go about making a method run only once and then stopping.

Here is where I check for collision:


	// Check for collision
		for (Obstacle obstacles : obstacleList) {
			obstacles.render();
			obstacles.update();

			if (obstacles.getCollision().overlaps(player.getCollision())
					&& obstacles.getAlive() == true && player.getTimedOut() == false) {
				currentLives--;
				obstacles.setDead();
				player.revive();
			}
		}

and this is the revive method in the player class:


public void revive(){
		
		timedOut = true;
		if(timedOut == true){
			reviveTime += 1;
			
			if(reviveTime >= 500){
				timedOut = false;
				reviveTime -= reviveTime;
			}
		}

I’m sorry if this question is even too simple for this sub-forum. I’m trying my best to learn as I go. Thank you for the help! ;D