boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
Programming版 - MFC里如何判断一个线程处在Wait的状态?
相关主题
如何GDB调试因pthread_cond_wait()阻塞的线程? (转载)
C++ 有没有像go routine/channel 一样的库/框架?
thread, semaphore, 问题。
科普贴,fusion IO
一般thread-safe access
pthread mutex能不能用与thread和process之间
怎么练习multi-threading,平常工作都是用Java框架
问个java String问题
matlab 问题
vert.x 3.1月底发布,一个重要功能fiber
相关话题的讨论汇总
话题: 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版参与讨论
相关主题
vert.x 3.1月底发布,一个重要功能fiber
Windows Thread API
面试问题一问 (转载)
Linux thread和NPTL thread什么关系? (转载)
请教一个线程同步的问题。
High Performance Computing Software Engineer needed -- Cary NC
腾讯开源tcp ip stack, f-stack。有用过的么?
[合集] c#整个就是个script language now,将来谁都能写
有必要学一学MFC吗?
programming windows求教
相关话题的讨论汇总
话题: thread话题: suspend话题: want话题: waiting话题: wait