简体   繁体   中英

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.

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.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM