線形化の順序はどの程度正確に決定されますか。次のコードの線形化の順序は、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();
}
}