Ok, this is probably the easiest way, but I am afraid not the safest one. What if I will access the eState member from the function (running in another thread) while this thread will write it? Is it possible to try to lock an already locked mutex receive an error or exception and know that if the mutex is not lockable another thread is still running, otherwise another thread is done... Would be that an option? If yes, I can't get it to work. On Tue, August 30, 2005 23:52, Christian Henning said:
I don't think you can do that with the thread lib. If you need to wait until a thread is finished you can use the join().
You can of course keep the state somewhere else. Like:
enum teThreadState { BLOCKED = 0, RUNNING, ... }
teThreadState eState;
void run() throw() { scoped_lock lock(mutex);
eState = RUNNING; doSomething();
eState = BLOCKED;
while( condition ) cond.wait( lock );
eState = RUNNING; }
Christian
With Kind Regards, Ovanes Markarian