I am implementing a function in java that must necessarily wait for a time, similar to javascript's setTimeout, which executes a piece of code after a defined time has elapsed.
For example the following javascript code:
setTimeout(function(){ alert("Hello"); }, 3000);
For now, the closest I've seen is creating a thread and pausing it:
thread.sleep
But I would like to know if there is an easier way.