I don't know how to use Notify and wait in my program but I am required to. The point of my program is that there are two threads, one which assigns the inputted object to the numbers 1-10 and another that reads them. Could anyone help.
package vairables;
public class Vairables {
public static void main(String[] args)
{
class IntegerHolder
{
String variable = null;
synchronized void insert(String v)
{
while (variable != null)
{
notify();
wait();
}
variable = v;
notify();
}
synchronized int extract()
{
while ( variable == null)
{
notify();
wait();
}
String temp = variable;
variable = null;
notify();
return temp;
}
}
}
}