Home » Core Java » Print natural numbers 1 to 100 using two threads

Print natural numbers 1 to 100 using two threads

4. Print natural numbers 1 to 100 using two threads without using wait or synchronized where one thread prints only odd number and other thread prints only even number ?
Solution :

Output::



N .B .The above solution can arise dead lock condition ,but it is rare.To resolve this issue ,i have used wait() and notifyAll() method.See the detailed solution below.
5. Print natural numbers 1 to 100 using two threads using wait or synchronized where one thread prints only odd number and other thread prints only even number?
Solution :

Output::


Leave a comment

Your email address will not be published. Required fields are marked *

17 − 13 =