Bhagyesh Chaudhari
Bhagyesh Chaudhari

Reputation: 129

delay in an java applet program without using threads

Is it possible in java to make the program to sleep or wait for a particular time peroid ?

As in C++ we do delay(1000);. I am writing a java applet which does not include threads, but I want it to delay the execution of some statements. Its a clock(Digital) applet. so I need to make part of my applet code to delay for 1 second.

Upvotes: 0

Views: 387

Answers (2)

Roberto Attias
Roberto Attias

Reputation: 1903

You don't want to do that. sleeping for a second in the Event Dispatching Thread will prevent any event processing during that time. One second may not be that much, but in general this is not a good practice.

What you want to do is setup a timer with a 1s period.

Upvotes: 1

andrewdleach
andrewdleach

Reputation: 2466

Yes. It is possible. Do a little research into the Thread.sleep() method as well as Timers as well as...

Upvotes: 0

Related Questions