Threads
Also: thread count
Quick answer
A thread is a separate line of execution inside a process, and a process can run several threads at the same time on different CPU cores. The Threads column in Activity Monitor shows how many threads each process currently has.
Most apps use many threads: one to draw the interface and handle clicks, and others for network requests, file access, and background work. A thread count in the dozens is normal for a large app.
The number of threads says little about how busy an app is. Most threads spend their time waiting. % CPU is the better measure of actual work.
Where to see thread counts
In Activity Monitor, click the CPU tab. The Threads column shows the count per process, and the bottom of the window shows the total number of threads and processes on the Mac.
In Terminal, ps -M -p <PID> lists the threads of a single process.
When a growing thread count matters
A thread count that keeps climbing over hours, without leveling off, can point to a bug where an app starts threads and never ends them. If that app also grows in memory or slows down, restarting it is a reasonable first step, and reporting it to the developer helps.
Why some apps have hundreds of threads
macOS gives apps a shared pool of worker threads through Grand Central Dispatch. When an app hands off many small tasks, such as decoding images or reading files, the pool can grow to handle them and shrink again later. That alone can add dozens of threads to a busy app.
Browsers, chat apps and code editors often run several processes, each with its own threads for drawing, networking, audio and scripts. Audio and video apps keep threads ready so playback never has to wait. Add these up and a few hundred threads in one large app is not unusual.
kernel_task often shows the largest count of all. It holds the threads the macOS kernel and its drivers use, and it is not a sign of a problem.
How to check the thread count of one app
- In Activity Monitor, select the process and double-click it, or click the Info button in the toolbar.
- The inspector window lists Threads along with Ports and Context Switches for that process.
- In Terminal, run
top -l 1 -pid <PID> -stats pid,command,th, replacing <PID> with the process ID from the PID column. The #TH value shows total threads, then running threads after the slash. - To sort every process by thread count, run
top -o th -stats pid,command,thand press q to exit.
Normal and worrying thread counts
The total matters less than the direction it moves over time.
- Normal: the count jumps when you open windows, start a download or begin an export, then falls back when the work is done.
- Normal: a steady, high count that stays about the same for hours.
- Worrying: a count that climbs all day and never falls, even while the app is idle.
- Worrying: a climbing thread count together with growing memory or a growing Ports count. That combination usually points to a leak in the app.
- Worrying: many running threads, shown after the slash in
top, in an app you are not using. It is doing work you did not ask for.
Threads and CPU cores
Having more threads than cores is normal. macOS switches cores between threads many times a second, and most threads are waiting anyway. Only running threads compete for a core.
The number of threads that can run at the same moment equals your logical core count from sysctl -n hw.logicalcpu. If more threads are ready than that, the extra ones wait, and that waiting is what raises the load average.
Questions people ask
What does Threads mean in Activity Monitor?
It is the number of threads a process is running. Threads let one app do several things at once, such as drawing its window while it downloads a file.
Is a high thread count bad?
Usually not. Large apps often have dozens or hundreds of threads, and most are idle. A count that grows without stopping is the pattern to watch for.
How are threads related to % CPU over 100?
A process can only use more than one core when it has more than one thread doing work at the same time. That is how % CPU goes over 100%.
How many threads can a Mac run at once?
One per logical core at the same instant. Run `sysctl -n hw.logicalcpu` to see the number. Thousands more can exist, but they take turns.
Does quitting an app free its threads?
Yes. When a process ends, all of its threads end with it. Restarting an app is the quickest way to reset a thread count that has grown too large.
Why does kernel_task have so many threads?
kernel_task is the macOS kernel, and its threads include those used by the kernel and its drivers. A large count there is normal.
Related
Looking for something better than Activity Monitor? See the best Activity Monitor alternatives for Mac, or browse every term in the glossary.