Print 1 2 3 infinitely using thread. Create three threads viz T1, T2, and T3 such that those should print 1 2 3 sequence infinitely.
Output :1 2 3 1 2 3 1 2 3 1 2 3 1 2 3 ......
Prerequisite : Threads in C
- Start an infinite loop and initialize a variable ‘done’ to 1.
- Now, check for the value of done is not equal to 1.
- If it is hold wait condition lock, else print n and respectively signal the next consecutive n.
1 2 3 1 2 3 1 2 3 1 2 3 ...
- Difference Between Daemon Threads and User Threads In Java
- Sharing a queue among three threads
- Maximum number of threads that can be created within a process in C
- Introducing Threads in Socket Programming in Java
- How to print a variable name in C?
- How to print % using printf()?
- How will you print numbers from 1 to 100 without using loop? | Set-2
- Program to print last 10 lines
- Print 1 to 100 in C++, without loop and recursion
- Print Hello World without semicolon in C/C++
- Print calendar for a given year in C++
- Condition To Print "HelloWord"
- Print "Even" or "Odd" without using conditional statement
- Print a long int in C using putchar() only
- How will you print numbers from 1 to 100 without using loop?
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.