Commit d845fef9 authored by Bryce Allen's avatar Bryce Allen Committed by Youness Alaoui
Browse files

Do not unref the GThread since g_thread_join takes the reference. Also rename the variable.

parent d34e48d0
...@@ -68,7 +68,7 @@ static void * example_thread(void *data); ...@@ -68,7 +68,7 @@ static void * example_thread(void *data);
int int
main(int argc, char *argv[]) main(int argc, char *argv[])
{ {
GThread *gloopthread; GThread *gexamplethread;
// Parse arguments // Parse arguments
if (argc > 4 || argc < 2 || argv[1][1] != '\0') { if (argc > 4 || argc < 2 || argv[1][1] != '\0') {
...@@ -97,13 +97,12 @@ main(int argc, char *argv[]) ...@@ -97,13 +97,12 @@ main(int argc, char *argv[])
// Run the mainloop and the example thread // Run the mainloop and the example thread
exit_thread = FALSE; exit_thread = FALSE;
gloopthread = g_thread_new("example thread", &example_thread, NULL); gexamplethread = g_thread_new("example thread", &example_thread, NULL);
g_main_loop_run (gloop); g_main_loop_run (gloop);
exit_thread = TRUE; exit_thread = TRUE;
g_main_loop_unref(gloop); g_main_loop_unref(gloop);
g_thread_join (gloopthread); g_thread_join (gexamplethread);
g_thread_unref (gloopthread);
return EXIT_SUCCESS; return EXIT_SUCCESS;
} }
......
...@@ -77,7 +77,7 @@ static void * example_thread(void *data); ...@@ -77,7 +77,7 @@ static void * example_thread(void *data);
int int
main(int argc, char *argv[]) main(int argc, char *argv[])
{ {
GThread *gloopthread; GThread *gexamplethread;
// Parse arguments // Parse arguments
if (argc > 4 || argc < 2 || argv[1][1] != '\0') { if (argc > 4 || argc < 2 || argv[1][1] != '\0') {
...@@ -106,13 +106,12 @@ main(int argc, char *argv[]) ...@@ -106,13 +106,12 @@ main(int argc, char *argv[])
// Run the mainloop and the example thread // Run the mainloop and the example thread
exit_thread = FALSE; exit_thread = FALSE;
gloopthread = g_thread_new("example thread", &example_thread, NULL); gexamplethread = g_thread_new("example thread", &example_thread, NULL);
g_main_loop_run (gloop); g_main_loop_run (gloop);
exit_thread = TRUE; exit_thread = TRUE;
g_main_loop_unref(gloop); g_main_loop_unref(gloop);
g_thread_join (gloopthread); g_thread_join (gexamplethread);
g_thread_unref (gloopthread);
return EXIT_SUCCESS; return EXIT_SUCCESS;
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment