Fix sizeof pointer error
Fix deprecated GLib functions

* GStaticMutex has been deprecated in GLib 2.32.
* g_mutex_new has been deprecated in GLib 2.32.
* Use #ifdefs to wrap the mutex functions.
* Check GLib version number when spawning threads.