开发者

How do I initialize the mutex locks and condition variables

pthread_mutex_t qlock[5] = PTHREAD_MUTEX_INITIALIZER;

pthread_cond_t qcon开发者_JS百科d[5] = PTHREAD_COND_INITIALIZER;

It is giving me error as follows...

error: array must be initialized with a brace-enclosed initializer

.. Please, can somebody debug this or tell me a way to solve it...


This initializes a mutex:

pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER;

This initializes an array:

int array[5] = { 0, 1, 2, 3,  4 };

...that should be enough to get you going.


I'd suggest you reading a beginner book on C programming language. See for example a related SO question.

BTW, at this level of C knowledge I would highly recommend you to stay away from multithreaded programming (at least with pthreads).

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜