grub2: bring back build of aros-side grub2 tools
[AROS.git] / test / misc / pthreadtest.c
blobc99a469725155e4caf551a921778d8623712e967
1 /*
2 Copyright © 2007-2014, The AROS Development Team. All rights reserved.
3 $Id$
4 */
7 #include <pthread.h>
8 #include <stdlib.h>
9 #include <stdio.h>
11 void *thread_func1( void *vptr_args );
12 void *thread_func2( void *vptr_args );
14 volatile int m;
16 int main ( void )
18 int j;
20 pthread_t thread1, thread2;
22 pthread_create( &thread1, NULL, &thread_func1, NULL );
23 printf("thread 1 created.. thread: %d\n", thread1);
25 pthread_create( &thread2, NULL, &thread_func2, NULL );
26 printf("thread 2 created.. thread: %d\n", thread2);
29 for( j= 0; j < 20; ++j )
31 printf("a\n");
33 for( m= 99999999; m; --m ); /* use some CPU time */
35 printf("trying to cancel thread 1\n");
36 pthread_cancel( thread1 );
40 printf("join thread 2\n");
41 pthread_join( thread2, NULL );
43 printf("finished!\n");
45 return 0;
48 volatile int f1, f2;
50 void *thread_func1( void *vptr_args )
52 int j;
54 for( j= 0; j < 20; ++j )
56 printf("b\n");
58 for( f1= 99999999; f1; --f1 ); /* use some CPU time */
61 printf("func1 end\n");
62 return NULL;
65 void *thread_func2( void *vptr_args )
67 int j;
69 for( j= 0; j < 20; ++j )
71 printf("c\n");
73 for( f2= 199999999; f2; --f2 ); /* use some CPU time */
76 printf("func2 end\n");
77 return NULL;