Threading question (avoiding deadlock)
- From: Pascal Haakmat <a haakmat chello nl>
- To: gtk-list gnome org, gtk-app-devel-list gnome org
- Subject: Threading question (avoiding deadlock)
- Date: Sun, 17 Mar 2002 03:06:15 +0100
Hello,
I was hoping somebody could point me in the right direction here.
I have a program with two (p)threads; one thread running the gtk_main()
event loop, and the other thread periodically updating the display in a
gdk_threads_enter() / gdk_threads_leave() block.
When the user presses a key in the event loop thread, the second thread
should die. However this opens up the possibility of deadlock:
thread 1: ---> pthread_cancel(thread 2) ---> pthread_join(thread 2)
thread 2: -----------------> gdk_threads_enter() ------------> deadlock
I can avoid this deadlock when I set the cancel type of the second thread to
PTHREAD_CANCEL_ASYNCHRONOUS, thereby forcing cancellation of the second
thread immediately. But somehow that doesn't seem wise. Can somebody please
advise?
Thanks.
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]