简体   繁体   中英

How to find the current state of a thread in the scheduler strucure in windows

I want to know the current state(SUSPENDED/READY/RUNNING/WAITING state ) of a thread which has been created by CreateThread() api.

How can I find it out?

My developement environment is Visual studio 2008 Expresss edition

also language is C/C++

/renjith g

As has been previously answered :-

Check if a Win32 thread is running or in a suspended state

APIs that provide this information are not provided because the information they return is stale before they return. If you want to know if a thread is suspended - call SuspendThread. Now you know (a) the thread has a suspend count of at least 1, and, as SuspendThread returns the 'previous' suspend count, you can know that, at some point during the call to SuspendThread, the suspend count was 0, or some number. The same logic holds for testing if a thread is "stuck" in WaitForXObject(s) :- until you've stopped the thread, you can't know the answer to that question safely.

您可能会发现此线程状态监视器 (免费)对于查看应用程序中的线程状态很有用。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM