• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 #include "test.h"
2 
3 void *
func(void * arg)4 func(void * arg)
5 {
6 	Sleep(1000);
7 	return arg;
8 }
9 
10 int
main(int argc,char * argv[])11 main(int argc, char * argv[])
12 {
13 	pthread_t id[4];
14 	int i;
15 	intptr_t result = 0;
16 
17 	/* Create a few threads and then exit. */
18 	for (i = 0; i < 4; i++)
19 	  {
20 	    assert(pthread_create(&id[i], NULL, func, ((void *) (size_t) i)) == 0);
21 	  }
22 
23 	for (i = 0; i < 4; i++)
24 	  {
25 	    assert(pthread_join(id[i], (void **) &result) == 0);
26 	    assert((int) result == i);
27 	  }
28 
29 	/* Success. */
30 	return 0;
31 }
32