setName("Producer"); this.q = q; this.out = out;
while (true) { double r = Math.random(); // Only goes forward 1/10 of the time if ((r*100) < 10) { String s = String.format("Inserted at %tc", new Date()); return s; } }
try { while (true) { q.put(produce()); } } catch (InterruptedException e) { out.printf("%s interrupted: %s", getName(), e.getMessage()); }