Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Java HELP!

LEGEND ,
Oct 11, 2006 Oct 11, 2006
I found this code to pause the execution of a page by a set amount of
seconds

I need to figure out how to use this in CF so I can pause the execution of a
loop.

Can anyone help?

public class Wait {
public static void oneSec() {
try {
Thread.currentThread().sleep(1000);
}
catch (InterruptedException e) {
e.printStackTrace();
}
}
}

Can I put it into a <cfscript> tag? Then how can I call it inside a loop?


TOPICS
Advanced techniques
472
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Oct 11, 2006 Oct 11, 2006
Nevermind, I did it a different way


Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Oct 11, 2006 Oct 11, 2006
Here is a call to the Thread.sleep method:
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Nov 04, 2006 Nov 04, 2006
Hi,

I'm trying to use the sleep script you provided and when I try to variblize the time using some calculations (see the example below) it throws the following error:

The selected method sleep was not found.
Either there are no methods with the specified method name and argument types, or the method sleep is overloaded with arguments types that ColdFusion can't decipher reliably. If this is a Java object and you verified that the method exists, you may need to use the javacast function to reduce ambiguity.

Example:

<cfset SleepSeconds = 1000 * 2>
<cfscript>
thrObj = CreateObject("java", "java.lang.Thread");
thrObj.sleep(#SleepSeconds#);
</cfscript>

Any Ideas would be greatly appreciated.
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Nov 05, 2006 Nov 05, 2006
shloime11 wrote:
> <cfset SleepSeconds = 1000 * 2>


> <cfscript>
> thrObj = CreateObject("java", "java.lang.Thread");
> thrObj.sleep(#SleepSeconds#);
> </cfscript>

sleep method is looking for a java "long". since you did some calculations on
SleepSeconds cf converts into a float (i think). use javacast

thrObj.sleep(javaCast("long",SleepSeconds));
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Nov 05, 2006 Nov 05, 2006
LATEST
Thanks! This did the trick
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources