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
Advertisement
Related Tutorial and Articles
Advertisements Advertisements
 

 

 

DMCA.com