gpt4 book ai didi

c - GHashTable (glib2) 线程安全吗?

转载 作者:太空狗 更新时间:2023-10-29 16:53:05 43 4
gpt4 key购买 nike

我有多个线程在 GHashTable 中添加、修改和查找数据。是线程安全的,还是需要自己实现线程安全?

最佳答案

The documentation很清楚地说明了这一点:

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 same GHashTable from multiple threads.

所以:不,哈希表不是线程安全的。

关于c - GHashTable (glib2) 线程安全吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8837822/

43 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com