Computer Science Canada Delaying |
Author: | JSBN [ Fri Jun 13, 2003 9:34 pm ] | ||
Post subject: | Delaying | ||
Uh... how do you do a delay in java? ie: in turing
|
Author: | octopi [ Fri Jun 13, 2003 11:54 pm ] |
Post subject: | |
I have no idea about java, or if this will even make sense to you, but a simple search on google spit out this Thread.sleep(DELAY); Where DELAY is a number, any number in milliseconds (I think) http://www.google.com |
Author: | JSBN [ Sat Jun 14, 2003 10:24 am ] |
Post subject: | |
i tried it but it just screws up my program :/ Thx for trying tho |
Author: | Tony [ Sat Jun 14, 2003 11:45 am ] |
Post subject: | |
You could just run a huge forloop calculating garbage values to waste time ![]() |
Author: | rizzix [ Wed Jun 18, 2003 11:20 pm ] | ||
Post subject: | |||
JSBN wrote: i tried it but it just screws up my program :/
Thx for trying tho hey dude! That is the way to do it. You see the only problem it does not work is cuz u haven't caught the exception that is thrown by the static method sleep of the class Thread. all you have to do is modify ur code to something like this..
basically make sure the Thread.sleep(int msec); is in the try block and that there is a following catch block to catch the InterruptedException exception. ^^ I'll have a tutorial on why we have this funny syntax in Java soon after my exams. You'll see this try/catch/final exception handling used extensively in Java. It's something u need to know. I'm planning on comming out with more tutorials to explain these concepts and more.. |
Author: | poseidon [ Wed Jul 23, 2003 10:46 pm ] |
Post subject: | random numbers |
Is there possibly another way to delay without using try/catch and all that exception stuff? dam .... doing java makes u appreciate the simplicity of turing .... one liners in turing are replaced w/ these long and complicated lines of bull in java. |
Author: | rizzix [ Thu Jul 24, 2003 3:05 pm ] | ||
Post subject: | |||
Turing isn't multi threaded.. Java on the other hand is.. Your application runs in the main thread.. form this thread u can create new threads.. since your application is a thread, it has to trap this interrupt exception. if ur sure ur not going spawn new threads ur self then u can try this:
now u can call this method without encapsulating it in a try/catch block. since the method it self handles the exception. |
Author: | poseidon [ Thu Jul 24, 2003 8:52 pm ] | ||
Post subject: | delaying | ||
hmmm ... alrite ill try ... btw ..... this is probably a stupid q ... but wat does
do? and wat's the purpose of the try/catch commands? is it used to "catch" or prevent errors or something btw thx man |
Author: | SilverSprite [ Thu Jul 24, 2003 10:05 pm ] |
Post subject: | |
Look in the tutorial section.. there is a tutorial on exception handling. |