blob: 144ce608d1f68c44efe9bab7fd2fc330cb735f1e [file] [log] [blame]
jsgf12475f62003-10-16 06:09:41 +00001/* All OK */
2
3#include <pthread.h>
4
5static pthread_mutex_t mx = PTHREAD_MUTEX_INITIALIZER;
6
7static int shared;
8
9static void *th(void *v)
10{
11 pthread_mutex_lock(&mx);
12 shared++;
13 pthread_mutex_unlock(&mx);
14
15 return 0;
16}
17
18int main()
19{
20 pthread_t a, b;
21
22 pthread_mutex_lock(&mx);
23 pthread_mutex_unlock(&mx);
24
25 pthread_create(&a, NULL, th, NULL);
26 pthread_create(&b, NULL, th, NULL);
27
28 pthread_join(a, NULL);
29 pthread_join(b, NULL);
30
31 return 0;
32}