Rob Gonda's Blog

Force CF to wait w/o killing the CPU

Many times we have been into the situation where we need to tell CF to wait a couple of seconds and try again. This task is usually easy, with the exception that we don’t want to kill the CPU… Easily we could set a timestamp, and start looping until we reach a target time after that. I downloaded from ColdFusion exchange a cfx tag that promised to accomplish this but it killed the CPU anyway.

So, here’s a little snippet to wait idle using the CF JVM.

function sleep(ms) {
 var thread = createObject("java","java.lang.Thread");
 thread.sleep(ms);
}

TrackBacks
There are no trackbacks for this entry.

Trackback URL for this entry:
http://www.robgonda.com/blog/trackback.cfm?91A4D787-2B3E-FB41-5CAF6276ECBE0025

Comments (Comment Moderation is enabled. Your comment will not appear until approved.)
This blog is running version 5.9.003. Contact Blog Owner