I need to pass buffer object which has generated values to construcor of reading class to print real time generated numbers.
Which is the best way to do it?
When I pass generated value I get the number but I need to pass values that are beeinig generated and writed during the thread execution?
public class Reader implements Runnable {
// private int randomN;
public Reader() {
// this.randomN = randomN;
}
and part of the the buffer class
private class Buffer extends JTextField
{
int n;
boolean valueSet = false;
synchronized int get() {
if (!valueSet)
try {
wait();
} catch (InterruptedException e) {
System.out.println("InterruptedException caught");
}
//System.out.println("Got: " + n);
valueSet = false;
notify();
return n;
}
from the assigment:
A class that is a subclass of JTextField that will be passed into the constructors of the two Threads mentioned next.
The access to this object will need to be coordinated by either explicit locking or by synchronizing.