Results 1 to 5 of 5
Hi,
I want to exit one thread from another thread. I pass thread_id to pthread_exit as
pthread_exit((void *)MQthread_id);
so it exit the current thread.
can anybody guide me on this.
...
- 11-24-2008 #1Just Joined!
- Join Date
- Feb 2008
- Posts
- 50
How to exit one thread from other thread
Hi,
I want to exit one thread from another thread. I pass thread_id to pthread_exit as
pthread_exit((void *)MQthread_id);
so it exit the current thread.
can anybody guide me on this.
Thanks
- 11-24-2008 #2Just Joined!
- Join Date
- Nov 2008
- Posts
- 25
personally I prefer setting a variable to let a thread know it should terminate rather than terminating it externally, as this may cause side-effects. I don't know if the thread you wish to end just keeps going on and on in an endless loop, if it does, I suggest checking at the end of each loop if a variable telling it to shut down has been set.
- 11-25-2008 #3Just Joined!
- Join Date
- Feb 2008
- Posts
- 50
Thanks morfanaion.. It is a good solution.
It is working fine now
But Is it possible with pthread_exit() from other function in above situation.?
- 11-25-2008 #4Just Joined!
- Join Date
- Nov 2008
- Posts
- 25
I suppose it would be, but to be quite frank, I couldn't say. Since I've always preferred threads to maintain control over themselves, I've never tried it.
- 11-25-2008 #5
Please, before posting questions, at least read the man page! :)
No.But Is it possible with pthread_exit() from other function in above situation.?
pthread_exit() does have one parameter, but that parameter serves a completely different purpose.
To find out what it's for, read the man page:
If that man page is not installed on your system, scroogle this:Code:man pthread_exit
Hope this helps.Code:Linux man pthread_exit
--
Bill
Old age and treachery will overcome youth and skill.


Reply With Quote