Name: mc57594 Date: 11/15/99
java version "1.2.2"
Classic VM (build JDK-1.2.2-W, native threads, symcjit)
The wait() and notify() methods should have a new Condition parameter, so that,
you can wait in different queues for different conditions. Example:
class Consumer {
...
if (num_elements == 0 )
wait (production);
<consume the element>
--num_elements;
notify (consumption)
...
}
class Producer {
...
if (num_elements == MAX )
wait (consumption);
<produce the element>
++num_elements;
notify (production)
...
}
The code is more clear, you avoid while loops and you avoid to wake up a process
that doesn't have to be notified. This is the natural way that monitors are
usually implemented.
(Review ID: 97799)
======================================================================
java version "1.2.2"
Classic VM (build JDK-1.2.2-W, native threads, symcjit)
The wait() and notify() methods should have a new Condition parameter, so that,
you can wait in different queues for different conditions. Example:
class Consumer {
...
if (num_elements == 0 )
wait (production);
<consume the element>
--num_elements;
notify (consumption)
...
}
class Producer {
...
if (num_elements == MAX )
wait (consumption);
<produce the element>
++num_elements;
notify (production)
...
}
The code is more clear, you avoid while loops and you avoid to wake up a process
that doesn't have to be notified. This is the natural way that monitors are
usually implemented.
(Review ID: 97799)
======================================================================