Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save aliaspooryorik/b3bfb3353d5c43b957893a378dbe974a to your computer and use it in GitHub Desktop.
Save aliaspooryorik/b3bfb3353d5c43b957893a378dbe974a to your computer and use it in GitHub Desktop.
cfthread scoping
<cfscript>
function foo() {
var i = 0;
local.j = 0;
local.cat = 1;
var bat = 2;
var args = {
x=0
};
while(i < 4) {
i++;
local.j++;
args.x++;
thread.y = i;
thread name="thread_#i#" action="run" args=args cat=local.cat i=i {
attributes.cat++;
attributes.args.x++;
thread.y += 10;
logit({
cat: attributes.cat,
x: attributes.args.x,
i: i
});
sleep(2);
}
}
thread action="join";
writeDump(args);
writeDump(thread);
writeDump(cfthread);
}
function logit(msg) {
writeOutput(serializeJSON(msg));
}
foo();
</cfscript>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment