# Each() deprecated

**URL:** <https://dev.lucee.org/t/each-deprecated/13134>\
**Category:** language\
**Created:** [October 20, 2023, 3:12pm UTC](https://dev.lucee.org/t/each-deprecated/13134 "2023-10-20T15:12:40Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![randy-johnson](https://dev.lucee.org/user_avatar/dev.lucee.org/randy-johnson/32/3744_2.png) [@randy-johnson](https://dev.lucee.org/u/randy-johnson)\
**Post date:** [October 20, 2023, 3:12pm UTC](https://dev.lucee.org/t/each-deprecated/13134/1 "2023-10-20T15:12:40Z")

</div>

Hello,

I found this page today about Lucee & threads: [Threads :: Lucee Documentation](https://docs.lucee.org/categories/thread.html)

I was reading the first blog article about Parallelism on Lucee that uses the `each()` function.

Viewing the docs I see it is deprecated.

Is the reason for that because we should be using the other types of each statements like array.each, query.each, etc?

On a separate note. Does the admin screen Services → Tasks → Maximum Concurrent Threads setting have to do with the threads that would be created with the each() functions with parallel = true?

---

<div class="post-metadata">

**Author:** ![andreas](https://dev.lucee.org/user_avatar/dev.lucee.org/andreas/32/3352_2.png) [@andreas](https://dev.lucee.org/u/andreas)\
**Post date:** [October 20, 2023, 7:31pm UTC](https://dev.lucee.org/t/each-deprecated/13134/2 "2023-10-20T19:31:28Z")

</div>

I think in part yes. But cfml has lots of iterating iterating functions: We have these functions for the various datatypes, plus we have also new functional programming functions (.map(),.reduce()), plus we can use `for(item in array)` and the legacy for/next and cfloop. That are a wide range of alternatives and we can use what fits best. Besides of that each() is soley a Lucee cfml function that hasn’t been adopted by ACF.

---

<div class="post-metadata">

**Author:** ![bennadel](https://dev.lucee.org/user_avatar/dev.lucee.org/bennadel/32/2110_2.png) [@bennadel](https://dev.lucee.org/u/bennadel)\
**Post date:** [October 21, 2023, 3:46pm UTC](https://dev.lucee.org/t/each-deprecated/13134/3 "2023-10-21T15:46:55Z")

</div>

Re: _“Services → Tasks → Maximum Concurrent Threads”_ question, I would _suspect_ this has more to do with Lucee’s specialized `CFThread`. By default, `CFThread` spawns a thread in the context of the current application. But, you can add `[type = "task"]` to the `CFThread` tag and Lucee will write the thread to disk as a _file_ and then execute _outside_ of the application context. My **guess** is that the thing you’re talking about is to determine how many of those task threads can be run in parallel?

But, I’m just shooting from the hip here.

---

<div class="post-metadata">

**Author:** ![randy-johnson](https://dev.lucee.org/user_avatar/dev.lucee.org/randy-johnson/32/3744_2.png) [@randy-johnson](https://dev.lucee.org/u/randy-johnson)\
**Post date:** [October 23, 2023, 10:35pm UTC](https://dev.lucee.org/t/each-deprecated/13134/4 "2023-10-23T22:35:09Z")

</div>

Hi Ben,

I was thinking the other day that if I had multiple pages running that used each() or one of the alternatives, there would be a setting that would prevent too many tasks from running at a time and overwhelming the server.

But from what I gather, I would use cfthread type=task and then the setting in the admin area, and they would be queued if the maximum concurrent threads are already running.

If that is how it works, I do see how that would be much better than having scheduled tasks.

---

<div class="post-metadata">

**Author:** ![bennadel](https://dev.lucee.org/user_avatar/dev.lucee.org/bennadel/32/2110_2.png) [@bennadel](https://dev.lucee.org/u/bennadel)\
**Post date:** [October 26, 2023, 3:10pm UTC](https://dev.lucee.org/t/each-deprecated/13134/5 "2023-10-26T15:10:03Z")

</div>

@randy-johnson to be clear, I don’t really have a great understanding of the low-level implications of running a lot of threads. I will say that I am cautious about it; but, I’ll also say that I don’t think I’ve ever seen it cause an issues (that I’ve been made aware of).
