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 ...
Attention reader! Don’t stop learning now. Get hold of all the important DSA concepts with the DSA Self Paced Course at a student-friendly price and become industry ready.
- Difference Between Daemon Threads and User Threads In Java
- Two way communication between Client and Server using Win32 Threads
- C++ File Writer-Reader application using Windows Threads
- Maximum number of threads that can be created within a process in C
- Introducing Threads in Socket Programming in Java
- Sharing a queue among three threads
- How will you print numbers from 1 to 100 without using loop?
- Write a C program to print "Geeks for Geeks" without using a semicolon
- How to print % using printf()?
- Print "Even" or "Odd" without using conditional statement
- Print a long int in C using putchar() only
- Print substring of a given string without using any string function and loop in C
- Print individual digits as words without using if or switch
- Print "Hello World" in C/C++ without using any header file
- C Program to print numbers from 1 to N without using semicolon?
- How to print a semicolon(;) without using semicolon in C/C++?
- Write a C program to print "GfG" repeatedly without using loop, recursion and any control structure?
- How to print a number 100 times without using loop and recursion in C?
- C program to print characters without using format specifiers
- Print a number 100 times without using loop, recursion and macro expansion 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.