开发者

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/WAITIN开发者_开发百科G 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.


You may find this Thread Status Monitor (free) useful for viewing the state of threads in your app.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜