What you want is a GStaticMutex
. Declare it as a static local variable in the thread function, and initialize it with G_STATIC_MUTEX_INIT
:
static GStaticMutex my_mutex = G_STATIC_MUTEX_INIT;
This declares, defines and initializes the mutex, so it can be used directly.
See the example in the linked reference.