The problem is to synchronize n number of threads using pthread library. The idea is take thread count and print 1 in first thread, print 2 in second thread, print 3 in third thread, ….. print n in nth thread and again repeat from thread 1 infinitely.
Prerequisite : Multithreading
Input : Thread count Output : 1 2 3 ... thread count 1 2 3 ... thread count 1 2 3 ... thread count .... Input : 5 Output : 1 2 3 4 5 1 2 3 4 5 1 2 3 4 5 1 2 3 4 5 1 2 3 4 5 1 2 3 4 5 ....
GeeksforGeeks has prepared a complete interview preparation course with premium videos, theory, practice problems, TA support and many more features. Please refer Placement 100 for details
- Difference between User Level thread and Kernel Level thread
- How will you print numbers from 1 to 100 without using loop? | Set-2
- How will you print numbers from 1 to 100 without using loop?
- C Program to print numbers from 1 to N without using semicolon?
- Program to print a pattern of numbers
- Program to Print Pyramid Pattern using numbers
- Thread functions in C/C++
- Thread in Operating System
- Thread get_id() function in C++
- Thread hardware_concurrency() function in C++
- Thread joinable() function in C++
- Thread States in Operating Systems
- Difference between Process and Kernel Thread
- Sequence Points in C | Set 1
- Get the stack size and set the stack size of thread attribute in C
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.