I have multiple threads adding, modifying and looking up data in GHashTable. Is it threadsafe, or do I need to implement threadsafety myself?
Asked
Active
Viewed 1,665 times
11
-
why someone would vote up this question as too localized ? This is good, reasonable and fair question. – Manuel Salvadores Jan 12 '12 at 17:24
1 Answers
16
The documentation states this pretty clearly:
After calling
g_thread_init()
, GLib is completely thread safe (all global data is automatically locked), but individual data structure instances are not automatically locked for performance reasons. So, for example you must coordinate accesses to the sameGHashTable
from multiple threads.
So: no, the hash table is not thread safe.

unwind
- 391,730
- 64
- 469
- 606