Computer Science Canada

delay in java

Author:  nate [ Fri Jan 16, 2004 9:43 am ]
Post subject:  delay in java

How do you do basically a delay in java?

in turing its delay (int)


so how would you draw a circle movinng around in an applet? I can make it move but you can barley see it because it does not delay.

Thanks

Author:  BlAcK TuRtLe [ Fri Jan 16, 2004 9:56 am ]
Post subject: 

just use a garbage delay. Throw in a bunch of calculations into a for structure. For example:
code:

for(int x=1;x<=9999999;x++)
{
b=x+29488-192943*444;
}

Author:  rizzix [ Fri Jan 16, 2004 3:19 pm ]
Post subject: 

hehe, well one thing is for sure every time u run that code it will have a different delay.

my suggestion use the languages builtin delay mechanism

all u need to do is call the method public static void Thread.sleep(long milliseconds), passing it a long value as the number of milliseconds u want the "main thread" of ur program to stop execution. It effectively is the same as turing's delay, but a little bit different in concept.


: