![]() ![]() It can also be used to port Unix software (which uses pthreads) with little or no modification to the Windows platform. Windows does not support the pthreads standard natively, therefore the Pthreads4w project seeks to provide a portable and open-source wrapper implementation. THREAD 3: Will be sleeping for 4 seconds. ![]() THREAD 4: Will be sleeping for 1 seconds. THREAD 2: Will be sleeping for 4 seconds. THREAD 1: Will be sleeping for 5 seconds. THREAD 0: Will be sleeping for 3 seconds. Here is one of the many possible outputs from running this program. Gcc pthreads_demo.c -pthread -o pthreads_demo This program can be compiled using the gcc compiler with the following command: If a programmer wanted the threads to communicate with each other, this would require defining a variable outside of the scope of any of the functions, making it a global variable. This program creates five threads, each executing the function perform_work that prints the unique number of this thread to standard output. #include #include #include #include #include #define NUM_THREADS 5 void * perform_work ( void * arguments ) ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |