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
- Introducing Threads in Socket Programming in Java
- Maximum number of threads that can be created within a process in C
- How to print a variable name in C?
- How to print % using printf()?
- Print Hello World without semicolon in C/C++
- How to Read and Print an Integer value in C
- How will you print numbers from 1 to 100 without using loop? | Set-2
- Print calendar for a given year in C++
- Print a long int in C using putchar() only
- Print 1 to 100 in C++, without loop and recursion
- Program to print last 10 lines
- Print "Even" or "Odd" without using conditional statement
- 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 firstname.lastname@example.org. 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.