Home Tutorialhelp Comment Questions * Object-Oriented programming

 
 

Comment

Satwant
Questions * Object-Oriented programming ,
March 22, 2009 at 10:57 PM

This small modification takes to desired result

class Shared {

int num=2;
boolean value = true;

synchronized int get() {
if (value==false)
try {
wait();
}
catch (InterruptedException e) {
System.out.println("InterruptedException caught");
}
System.out.println("consume: " + num);
value=false;
notify();
return num;
}
View All Comments | View Tutorial
Related Tutorial and Articles

Ask Questions?

If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.

Ask your questions, our development team will try to give answers to your questions.