zeroPrinted
and currentNumber
.zero
method, use a synchronized block to wait until zeroPrinted
is false, print 0
, set zeroPrinted
to true, and notify all waiting threads.even
method, use a synchronized block to wait until currentNumber
is even and zeroPrinted
is true, print the current number, increment currentNumber
, set zeroPrinted
to false, and notify all waiting threads.odd
method, use a synchronized block to wait until currentNumber
is odd and zeroPrinted
is true, print the current number, increment currentNumber
, set zeroPrinted
to false, and notify all waiting threads.currentNumber
exceeds n
.