Hi, we are looking at this documentation below. T...
# documentation
p
Hi, we are looking at this documentation below. There are two different scopes listed there: THREAD SCOPES Each thread has three special scopes: • The thread-local scope is an implicit scope that contains variables that are available only to the thread, and exist only for the life of the thread. • The Thread scope is available to the page and to all other threads started from the page. Its data remains available until the page and all threads started from the page finish, even if the page finishes before the threads complete processing. • The Attributes scope contains attributes that are passed to the scope, and is available only within the thread and only for the life of the thread. • For detailed information about using ColdFusion scopes in threads, see Using ColdFusion Threads in the Developing ColdFusion Applications.All threads in a page share a single Variables scope, so you can use it for data that is common across all threads. You must be careful to lock access to the variables, if necessary, to prevent deadlocks or race conditions between threads. Our standard so far, is to use the thread scope in all threads (even on the pages that just create single thread and don't do any thread joins), but we started looking to see if maybe using thread-local scope would be better suited or have advantages over using thread scope for the cases when threads are used in serial order instead of parallel or when there is only one thread on the page and no information needs to be accessed on the page outside the scope. Does anyone have any practical examples of when to use thread-local scope vs. thread scope?
d
Typically I use thread-local unless or until I need results back from the thread to share (either with other threads or the page). So, all internal data processing uses the thread-local (default/implicit) scope, only when a result of that processing needs to be available outside that thread do I then use the thread scope.
p
Thanks!