线性化顺序是如何确定的。怎么能说下面代码的线性化顺序就是wait()释放的顺序。如何检查代码是否可线性化?
class Buffer
{
int in = 0;
int out = 0;
int numElems = 0;
synchronized void put(E elem) throws InterruptedException
{
while (!numElems < N)
{
wait();
}
buff[in] = elem;
in = (in + 1) % N;
notifyAll();
}
synchronized E take() throws InterruptedException
{
while (!numElems > 0)
{
wait();
}
E temp = buff[out];
out = (out + 1) % N;
return temp;
notifyAll();
}
}