Printing Even and Odd using two Threads in Java

Write a java program to print even and odd values in sequence.
Expected result:
Odd:1
Even:2
Odd:3
Even:4
Odd:5
Even:6
Odd:7
Even:8
Odd:9

Solution 1:
Solution 2: Java 8
Output :
Odd:1
Even:2
Odd:3
Even:4
Odd:5
Even:6
Odd:7
Even:8
Odd:9
Even:10

SHARE
    Blogger Comment
    Facebook Comment