public class Producent extends Thread { private String id; private Bufor buff; private int powt; public Producent(String _id, Bufor _buff, int _powt) { this.id = _id; this.buff = _buff; this.powt = _powt; } public void run() { for (int i = 0; i < this.powt; i++) { synchronized (buff) { String in = "Dana = [" + this.id + ", " + i + ", " + (int) (Math.random() * 100) + "]"; buff.add(in); //System.out.println("[" + this.id + ", " + i + "] >> " + in); System.out.println(in); try { sleep((int) (Math.random() * 10) + 1); } catch (InterruptedException e) { } } } } }