cfthreadtag & the
threadconstruct. Threads are independent streams of execution, and multiple threads on a page can execute simultaneously and asynchronously, letting you perform asynchronous processing in CFML. CFML code within the
cfthreadtag body executes on a separate thread while the page request thread continues processing without waiting for the
cfthreadbody to finish. You can allow the thread body to continue executing in the background or you can wait for it to finish.
runAsync()function or parallel Java streams using the cbStreams project. Please see our Asynchronous Programming section for information on advanced asynchronous programming.
writedump() + abortcombo usually goes into ether. Logging will be your best friend and outputting logs to the console for debugging purposes.
systemOutput( obj, addNewLine:boolean, doErrorStream:boolean)- Writes the given text or complex objects to the output or error stream. Complex objects are outputted as JSON. (Lucee-only) https://cfdocs.org/systemoutput
threadis extremely easy, just use the construct, give it a few attributes an boom you are in multi-threaded land. In tags you can use the
localscope. Any variable that you define inside the
threadbody without specifying a scope name prefix is in the thread local scope and cannot be accessed or modified by other threads.
Threadscope contains thread-specific variables and metadata about the thread. Only the owning thread can write data to this scope, but the page thread and all other threads in a request can read the variable values in this scope. Thread scope data remains available until the page and all threads that started from the page finish, even if the page finishes before the threads complete processing. So be careful with what you store in this scope or you can create memory leaks.
threadscope or actually the name of the thread as well, which is pretty cool.
threadconstruct you can use the name of the thread or the thread scope, but you must reference which thread scope within it using it's name:
threadconstruct as a name-value pair. The CFML engine will then place those in the thread's
attributesscope so they can be used for the life of the thread.