There are several occasions when we need to stop processing the page for a period of time. Before the release of Coldfusion 8, we could use Java’s sleep function to do that. The purpose of this post is to list the ways available to make a thread sleep in server side code.
Here is the first one, the most common one :-
[xml]<cfset javaObj = createObject("java", "java.lang.Thread")>
<cfset javaObj.sleep(1000) />[/xml]
With the release of Coldfusion 8, we can now also use the native .NET objects from within Coldfusion, here is how this can be done using .NET objects.
[xml]
<cfset netObj = createObject("dotnet","System.Threading.Thread")>
<cfset netObj.sleep(1000) />[/xml]
And last but not the least, Coldfusion 8 supports this via the CFTHREAD tag as well.
[xml]<cfthread action="sleep" duration="1000" />[/xml]
And we can do it via the Sleep function as well
[xml]<cfset sleep(1000) />[/xml]