– Common Function Library Project


Last updated February 10, 2005


Joe Bernard

Version: 1 | Requires: CF6 | Library: UtilityLib

By default, ColdFusion (by way of Java) schedules all threads to run at a priority of 5. This means that computing cycles are distributed to each thread evenly. This function allows you to adjust that priority and tell CF (Java) which threads are more important and which can wait. This function is great for utility applications that run in the background and hog the CPU. By setting those apps to a lower priority, they will yield system resources to other requests, such as requests to your web site. Conversely you can set mission critical apps to a higher priority ensuring that they can max out system resources if they need to.

Return Values:
Returns a boolean.


<cfset foo = setThreadPriority(3)>


Name Description Required
newPriority Thread priority. Yes

Full UDF Source:

 * Allows you to set the scheduling priority of the current thread.
 * @param newPriority 	 Thread priority. (Required)
 * @return Returns a boolean. 
 * @author Joe Bernard ( 
 * @version 1, February 10, 2005 
function setThreadPriority(newPriority) {
	var thread = createObject("java", "java.lang.Thread");
	if (arguments.newPriority le thread.max_priority and arguments.newPriority ge thread.min_priority) {
		return true;
	} else {
		return false;
blog comments powered by Disqus


Latest Additions

Kevin Cotton added
May 5, 2016

Raymond Camden added
April 25, 2016

Chris Wigginton added
January 18, 2016

Gary Stanton added
November 19, 2015

Sebastiaan Naafs - van Dijk added
November 13, 2015

Created by Raymond Camden / Design by Justin Johnson