Hi
I have a question which needs some expert advise . I have a class which looks like this
class A
{
public int i = 0;
public int read()
{
return i;
}
public void write()
{
i++;
}
}
This program needs to be modified in a such a way that
1. Two threads should be able to read the value of i
2. Two threads should not be able to write at a time
3.
Read should not be allowed when write is happening because of some thread Can any one let me know the best way of doing this ??