More questions on threads
- From: Colin Thomas <colin designresources co uk>
- To: gtk-app-devel-list gnome org
- Cc: colin designresources co uk
- Subject: More questions on threads
- Date: Thu, 5 Jul 2001 11:13:54 +0100 (BST)
Hi,
I now seem to have acquired the ability for none of the following to stop a gtk
program, which has had threads running in it!
gtk_main_quit()
gtk_exit(0)
exit(0)
All still leave the GUI hanging!
Only abort() will get rid of it ?
In my main routine I have:
#############################
g_thread_init(NULL);
gtk_set_locale ();
gtk_init (&argc, &argv);
.
.
.
gdk_threads_enter();
gtk_main();
gdk_threads_leave();
#############################
In my thread code, I G_LOCK/UNLOCK shared variables
When I need to access gtk functions I defered thread cancelation via:
#############################
////////////////////////
status = pthread_setcancelstate ( PTHREAD_CANCEL_DISABLE, &state);
////////////////////////
// get GTK thread lock
gdk_threads_enter();
////////////////////////
GTK FUNCTIONS..
////////////////////////
//release GTK thread lock
gdk_threads_leave();
////////////////////////
status = pthread_setcancelstate ( state, &state);
#############################
The threads are only allowed to cancel at defined cancellation points:
#############################
pthread_testcancel();
#############################
The main thread, cancels the child thread via:
#############################
int CancelCode = pthread_cancel(ThreadId);
int JoinCode = pthread_join (ThreadId ,&JoinResult);
#############################
If the thread is not run, then gtk_main_quit/gtk_exit/exit are okay ;-?
Any thoughts what might be causing this ??
I look forward to your thoughts.
best regards
/colin/
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]