How to Execute a Block of Code with 1 Second Intervals?
I Need to Execute a Block Every 1 Second, but It Needs to Be in the Same Thread. This Means, from What I Understand, That I Can't Make the Use of a Timer...
I need to execute a block every 1 second, but it needs to be in the same thread. This means, from what I understand, that I can't make the use of a timer class.
Is there a way to do what I want?
1 Answer
Create a thread and write a loop like so -
while(true)
{
// do something
Thread.sleep(1000);
}