Click here to Skip to main content
15,901,505 members

Welcome to the Lounge

   

For discussing anything related to a software developer's life but is not for programming questions. Got a programming question?

The Lounge is rated Safe For Work. If you're about to post something inappropriate for a shared office environment, then don't post it. No ads, no abuse, and no programming questions. Trolling, (political, climate, religious or whatever) will result in your account being removed.

 
GeneralRe: What are all those threads in Windows doing? Pin
obermd12-Jul-18 10:22
obermd12-Jul-18 10:22 
GeneralRe: What are all those threads in Windows doing? Pin
DRHuff11-Jul-18 9:24
DRHuff11-Jul-18 9:24 
GeneralRe: What are all those threads in Windows doing? Pin
Nelek11-Jul-18 20:01
protectorNelek11-Jul-18 20:01 
GeneralRe: What are all those threads in Windows doing? Pin
TNCaver12-Jul-18 7:41
TNCaver12-Jul-18 7:41 
GeneralRe: What are all those threads in Windows doing? Pin
Gary Wheeler11-Jul-18 7:20
Gary Wheeler11-Jul-18 7:20 
GeneralRe: What are all those threads in Windows doing? Pin
raddevus11-Jul-18 8:46
mvaraddevus11-Jul-18 8:46 
GeneralRe: What are all those threads in Windows doing? Pin
Marc Clifton11-Jul-18 11:36
mvaMarc Clifton11-Jul-18 11:36 
GeneralRe: What are all those threads in Windows doing? Pin
kalberts11-Jul-18 21:56
kalberts11-Jul-18 21:56 
Most likely they are doing nothing. Just waiting. All the resources they consume are a few bytes of RAM - or, if they haven't been active for a while, those bytes may even be out on a paging device, if you are short of RAM. (But who are, nowadays?)

Most likely, only a small handful of them are actively running at any one time. The great, great majority is waiting for "something". Maybe for some data structure to be unlocked by some other thread. Maybe that other thread is waiting for input data, that be from an interactive user, from another thread, from the network. A great number of threads in services are waiting for their time: They execute regularly - maybe every second, maybe every three months.

It all depends on the specific application, or service, or whatever. There are tools for obtaining the state of all threads - I never had the need for doing that in Windows, so I can't tell the details, but it looks as if the Sysinternals "PsList.exe -d" might be what you want. You'll see that almost all the threads are in 'Wait' state - but you won't know what they are waiting for without access to the source code. In many cases you also need to inspect runtime data structures to get the details. Unless you go into the threads of a specific process, it really doesn't give you much extra information: You know they are waiting, and it really doesn't matter what they are waiting for, other than the one specific process you are debugging at the moment.

Say, you get to know that a fair share of them is waiting for I/O (the ThreadWaitReason enum provides a certain breakdown - but I am not sure that dotNet thread states and Windows states are 100% identical; I believe dotNet threads are dynamically mapped to a pool of Windows threads). So what? You have to go further: What kind of I/O? Maybe mouse movements. Maybe for some output operation to complete. Maybe a TCP channel. Maybe for disk data. Maybe for a keyboard. You need to know which keyboard (or whatever physical or logical device) to be able to go further with it. If you identify a keyboard, what kind of input is it waiting for - a password entry, plain text, an amount, ...? To know that, you'd have to investigate the higher levels of the application; the thread state alone can't tell you what the input will be used for. Then you can go to the person at that keyboard and tell him/her: Go on, now, type in those values - lots of other threads are waiting for them!

... or something like that. In which other ways would you be utilizing information about what each of the two thousand threads are waiting for? You can make use of that info only for a single process, or maybe a small handful of them.

So, even if you could get the information you are asking for, there is very little you can do with that information, without spending a lot of effort. More than you would want to just for satisfying your curiosity. Smile | :)
GeneralRe: What are all those threads in Windows doing? Pin
Stuart Dootson12-Jul-18 6:24
professionalStuart Dootson12-Jul-18 6:24 
QuestionHow do you handle this? Pin
Eytukan11-Jul-18 3:44
Eytukan11-Jul-18 3:44 
AnswerRe: How do you handle this? Pin
Marc Clifton11-Jul-18 3:48
mvaMarc Clifton11-Jul-18 3:48 
GeneralRe: How do you handle this? Pin
Eytukan11-Jul-18 4:00
Eytukan11-Jul-18 4:00 
GeneralRe: How do you handle this? Pin
raddevus11-Jul-18 4:53
mvaraddevus11-Jul-18 4:53 
GeneralRe: How do you handle this? Pin
Eytukan11-Jul-18 7:56
Eytukan11-Jul-18 7:56 
GeneralRe: How do you handle this? Pin
Marc Clifton11-Jul-18 11:39
mvaMarc Clifton11-Jul-18 11:39 
AnswerRe: How do you handle this? Pin
Eddy Vluggen11-Jul-18 4:52
professionalEddy Vluggen11-Jul-18 4:52 
GeneralRe: How do you handle this? Pin
Eytukan11-Jul-18 7:57
Eytukan11-Jul-18 7:57 
AnswerRe: How do you handle this? Pin
Mycroft Holmes11-Jul-18 15:40
professionalMycroft Holmes11-Jul-18 15:40 
AnswerRe: How do you handle this? Pin
Nelek11-Jul-18 20:09
protectorNelek11-Jul-18 20:09 
GeneralWell, if we beat Croatia, I might have to go to the pub and sing the Marseillaise! Pin
Munchies_Matt11-Jul-18 3:22
Munchies_Matt11-Jul-18 3:22 
GeneralRe: Well, if we beat Croatia, I might have to go to the pub and sing the Marseillaise! Pin
Rage11-Jul-18 3:34
professionalRage11-Jul-18 3:34 
GeneralRe: Well, if we beat Croatia, I might have to go to the pub and sing the Marseillaise! Pin
Munchies_Matt11-Jul-18 3:38
Munchies_Matt11-Jul-18 3:38 
GeneralRe: Well, if we beat Croatia, I might have to go to the pub and sing the Marseillaise! Pin
Eytukan11-Jul-18 4:07
Eytukan11-Jul-18 4:07 
GeneralRe: Well, if we beat Croatia, I might have to go to the pub and sing the Marseillaise! Pin
Rage11-Jul-18 13:44
professionalRage11-Jul-18 13:44 
GeneralRe: Well, if we beat Croatia, I might have to go to the pub and sing the Marseillaise! Pin
Eytukan11-Jul-18 17:55
Eytukan11-Jul-18 17:55 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.