Re: Query whether a thread is running



andras toth schrieb:
Hello!

Is it possible to query somehow whether a Glib::Thread * instance is running?
Does the joinable() method do this or does it just return the flag
that was given to the Thread::create() ?
Of course I could just have a separate bool flag for each thread which
I update manually, but I was wondering if there is some better
solution.


Hi Andreas,

for what exactly do you need this?

The easiest way to know the thread's lifetime is to know when you have created the thread and then joining it.

Otherwise there is no other way than to maintain your own flag in the executing slot (you would still need to join() a joinable thread, though). joinable() only tells you whether you've created the thread previously with joinable=true. join() blocks until the thread finishes and it cleans up any resources - i.e. the thread object gets destroyed and the pointer to it is no longer valid.

Klaus


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]