Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save trycf/51d027bc0cde2402e87a8e664ed27033 to your computer and use it in GitHub Desktop.

Select an option

Save trycf/51d027bc0cde2402e87a8e664ed27033 to your computer and use it in GitHub Desktop.
TryCF Gist
<cfscript>
threadSize = 200;
threadList = [];
for( i=1; i <= threadSize; i++ ){
threadName = "thread_test_#i#_" & replace(createUUID(), "-", "", "all");
threadList.append(threadName);
thread action="run" name="#threadName#" {
thread.started = true;
thread.errored = false;
thread.finished = false;
try {
sleep(randRange(500, 1500));
throw "here";
} catch (Any e){
thread.errored = true;
}
thread.finished = true;
}
}
thread action="join" name="#threadList.toList()#" timeout="60000";
while(true){
allFinished = true;
structEach(cfthread, function(tname, tresult){
if( !structKeyExists(tresult,"finished") || !tresult.finished ){
allFinished = false;
}
});
if(allFinished) break;
sleep(50);
}
structEach(cfthread, function(tname, tresult){
if( !tresult.finished ){
dump(tresult);
}
});
</cfscript>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment