PTHREAD_MUTEX_INITIALIZER vs pthread_mutex_init ( &mutex, param)

前端 未结 4 696
庸人自扰
庸人自扰 2020-12-07 14:55

Is there any difference between

pthread_mutex_t lock = PTHREAD_MUTEX_INITIALIZER;

Or

pthread_mutex_t lock         


        
4条回答
  •  南笙
    南笙 (楼主)
    2020-12-07 15:21

    You can set more attributes of the mutex with the dynamic initialisation, plus you can only use the dynamic method if you're adding a bunch of mutexes at run time.

    There's nothing wrong with the static approach though, if that fits your needs.

提交回复
热议问题