Put doesn't work
Why doesn't this work? :(
It's the object to char that is wrong. If I type buf.put(2); below it works fine...
In class Producer
private CharacterFactory cf;
buf.put((Object)(cf.returnChar()));
In class CharacterFactory
public Object returnChar(){
Object tmp = (Object)(alphabet.get((int)((Math.random())*24)));
return tmp;
}
In class Buffer
publicsynchronizedvoid put(Object obj){
buffer.add(obj);
notify();
}
Exception in thread "Thread-3" java.lang.NullPointerException
at Producer.run(Producer.java:22)
at java.lang.Thread.run(Unknown Source)
Exception in thread "Thread-4" java.lang.NullPointerException
at Producer.run(Producer.java:22)
at java.lang.Thread.run(Unknown Source)
Exception in thread "Thread-5" java.lang.NullPointerException
at Producer.run(Producer.java:22)
at java.lang.Thread.run(Unknown Source)
Message was edited by:
_Robb_
Message was edited by:
_Robb_

