Threads Programs
1. Write a C program that demonstrates the creation and execution of a thread using the POSIX Threads (pthreads) API. The program should:
- Define a function printMessage() that will be executed by the thread
- Create a thread using the pthread_create() function
- Pass the printMessage() function as an argument to pthread_create()
- Wait for the thread to finish execution using the pthread_join() function
- Print a message indicating that the thread has finished execution
2. Write a C program that demonstrates the creation and execution of a thread using the POSIX Threads (pthreads) API. The program should:
- Define a function thread_function() that will be executed by the thread
- Declare a thread a_thread and create it using pthread_create()
- Pass the thread_function() function as an argument to pthread_create()
- Wait for the thread to finish execution using pthread_join()
- Print messages from both the main program and the thread.
3. Using threads passing two arguments and sum it and show output.
4. Using threads write a C program for find factorial.
0 Comments