amit.hak50 0 Junior Poster in Training

Create 2 Thread classes.One Thread is Incrementor and has one variable cnt1 with initial Value 0. Incrementor thread increments value of cnt1 by 1 each time. The other thread is Decrementor which has variable cnt2 with initial value 100. Decrementor thread decrements value of cnt2 by 1 each time.
- Incrementor thread increments value of cnt1 by one and notifies the other thread about this value
- The decrementor thread decrements value of its variable cnt2 by one and compares values of cnt1 and cnt2. If values of cnt1 and cnt2 are different then notifies the Incrementor thread and above mentioned step is repeated.
- But if values of cnt1 and cnt2 are matching then following message is displayed
Matching Value : 50
- Now Decrementor thread sets a flag as true and notifies the other thread and stops its execution.
- As flag is set to true, Incrementor thread understands that matching has occurred and stops its execution
NOTE : In this example use of wait ( ) , notify ( ) and synchronize statements is expected.
if anyone have information rearding this please help me out .thanx in advance ,