Revision 21448,
898 bytes
checked in by ghudson, 20 years ago
(diff) |
This commit was generated by cvs2svn to compensate for changes in r21447,
which included commits to RCS files with non-trunk default branches.
|
Line | |
---|
1 | #include <glib.h> |
---|
2 | |
---|
3 | GStaticRecMutex mutex = G_STATIC_REC_MUTEX_INIT; |
---|
4 | |
---|
5 | static void * |
---|
6 | thread1 (void *t) |
---|
7 | { |
---|
8 | gint i = 0; |
---|
9 | |
---|
10 | while (TRUE) { |
---|
11 | g_static_rec_mutex_lock (&mutex); |
---|
12 | if (i++ % 100000 == 0) |
---|
13 | g_print ("*"); |
---|
14 | g_static_rec_mutex_unlock (&mutex); |
---|
15 | if (i++ % 100000 == 0) |
---|
16 | g_print ("*"); |
---|
17 | } |
---|
18 | return NULL; |
---|
19 | } |
---|
20 | |
---|
21 | static void * |
---|
22 | thread2 (void *t) |
---|
23 | { |
---|
24 | gint i = 0; |
---|
25 | |
---|
26 | while (TRUE) { |
---|
27 | g_static_rec_mutex_lock (&mutex); |
---|
28 | if (i++ % 100000 == 0) |
---|
29 | g_print ("."); |
---|
30 | g_static_rec_mutex_unlock (&mutex); |
---|
31 | if (i++ % 100000 == 0) |
---|
32 | g_print ("."); |
---|
33 | } |
---|
34 | return NULL; |
---|
35 | } |
---|
36 | |
---|
37 | int |
---|
38 | main (gint argc, gchar * argv[]) |
---|
39 | { |
---|
40 | g_thread_init (NULL); |
---|
41 | g_thread_create_full (thread1, |
---|
42 | NULL, 0x200000, FALSE, TRUE, G_THREAD_PRIORITY_NORMAL, NULL); |
---|
43 | g_thread_create_full (thread2, |
---|
44 | NULL, 0x200000, FALSE, TRUE, G_THREAD_PRIORITY_NORMAL, NULL); |
---|
45 | |
---|
46 | g_usleep (G_MAXLONG); |
---|
47 | |
---|
48 | return 0; |
---|
49 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.