gstreamer/tests/old/testsuite/threads/staticrec.c
Wim Taymans 8448b21439 Added missing tests
Original commit message from CVS:
Added missing tests
2004-09-09 08:56:51 +00:00

49 lines
898 B
C

#include <glib.h>
GStaticRecMutex mutex = G_STATIC_REC_MUTEX_INIT;
static void *
thread1 (void *t)
{
gint i = 0;
while (TRUE) {
g_static_rec_mutex_lock (&mutex);
if (i++ % 100000 == 0)
g_print ("*");
g_static_rec_mutex_unlock (&mutex);
if (i++ % 100000 == 0)
g_print ("*");
}
return NULL;
}
static void *
thread2 (void *t)
{
gint i = 0;
while (TRUE) {
g_static_rec_mutex_lock (&mutex);
if (i++ % 100000 == 0)
g_print (".");
g_static_rec_mutex_unlock (&mutex);
if (i++ % 100000 == 0)
g_print (".");
}
return NULL;
}
int
main (gint argc, gchar * argv[])
{
g_thread_init (NULL);
g_thread_create_full (thread1,
NULL, 0x200000, FALSE, TRUE, G_THREAD_PRIORITY_NORMAL, NULL);
g_thread_create_full (thread2,
NULL, 0x200000, FALSE, TRUE, G_THREAD_PRIORITY_NORMAL, NULL);
g_usleep (G_MAXLONG);
return 0;
}