由买买提看人间百态

boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
Programming版 - MFC里如何判断一个线程处在Wait的状态?
相关主题
如何GDB调试因pthread_cond_wait()阻塞的线程? (转载)matlab 问题
C++ 有没有像go routine/channel 一样的库/框架?vert.x 3.1月底发布,一个重要功能fiber
thread, semaphore, 问题。Windows Thread API
科普贴,fusion IO面试问题一问 (转载)
一般thread-safe accessLinux thread和NPTL thread什么关系? (转载)
pthread mutex能不能用与thread和process之间请教一个线程同步的问题。
怎么练习multi-threading,平常工作都是用Java框架High Performance Computing Software Engineer needed -- Cary NC
问个java String问题腾讯开源tcp ip stack, f-stack。有用过的么?
相关话题的讨论汇总
话题: thread话题: suspend话题: want话题: waiting话题: wait
进入Programming版参与讨论
1 (共1页)
d******i
发帖数: 7160
1
或者被Suspend的状态?
谢谢!
d******i
发帖数: 7160
2
anyone knows?
X****r
发帖数: 3557
3
Why do you want this piece of information?
I don't think there is such API, even there is,
by the time the API returns the thread state could
already be different.
One way to do it (probably not what you want) is
to call SuspendThread. It returns the thread's
previous suspend count, in addition to suspend the
thread. So now you know both its previous state,
and its current state. Call ResumeThread afterwards
if you don't intend to suspend the thread.

【在 d******i 的大作中提到】
: 或者被Suspend的状态?
: 谢谢!

d******i
发帖数: 7160
4
the thing is a thread is waiting there by ITSELF, not a result of an
external suspending action.
IMO, external suspending is not recommended for a safe programming since the
caller has no idea of the point where the suspended thread stops.

【在 X****r 的大作中提到】
: Why do you want this piece of information?
: I don't think there is such API, even there is,
: by the time the API returns the thread state could
: already be different.
: One way to do it (probably not what you want) is
: to call SuspendThread. It returns the thread's
: previous suspend count, in addition to suspend the
: thread. So now you know both its previous state,
: and its current state. Call ResumeThread afterwards
: if you don't intend to suspend the thread.

X****r
发帖数: 3557
5
Again, why you want to know whether a thread is waiting or not?
If you want to synchronize execution of threads, just use
synchronization functions. If you want your worker thread
can be ended while waiting for some object, make it wait for
multiple objects instead, and let your control thread signal
an object to tell it to exit. Only synchronization functions
are safe when communicating between threads. If you attempt
to check whether or not the worker thread is waiting from the
control thread, the information you get could already be
out-of-date and you still can't safely terminate it anyhow.

the

【在 d******i 的大作中提到】
: the thing is a thread is waiting there by ITSELF, not a result of an
: external suspending action.
: IMO, external suspending is not recommended for a safe programming since the
: caller has no idea of the point where the suspended thread stops.

1 (共1页)
进入Programming版参与讨论
相关主题
腾讯开源tcp ip stack, f-stack。有用过的么?一般thread-safe access
[合集] c#整个就是个script language now,将来谁都能写pthread mutex能不能用与thread和process之间
有必要学一学MFC吗?怎么练习multi-threading,平常工作都是用Java框架
programming windows求教问个java String问题
如何GDB调试因pthread_cond_wait()阻塞的线程? (转载)matlab 问题
C++ 有没有像go routine/channel 一样的库/框架?vert.x 3.1月底发布,一个重要功能fiber
thread, semaphore, 问题。Windows Thread API
科普贴,fusion IO面试问题一问 (转载)
相关话题的讨论汇总
话题: thread话题: suspend话题: want话题: waiting话题: wait