public class Konsument extends Thread { private String id; private Bufor buff; private int powt; public Konsument(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++) { if(buff.check()){ break; } String temp = buff.get(); if(temp != "-1") System.out.println("[" + this.id + ", " + i + "] >> " + temp); else break; try { sleep((int) (Math.random() * 11) + 2); } catch (InterruptedException e) { } } } }