import java.util.Random; public class Player extends Thread { public static Random random = new Random( 453344 ); int id = 0; String name = ""; Shared game; Player(String name, Shared game) { this.id = game.dodajGracza(); this.name = name; this.game = game; } public int getIlosc() { try { Player.sleep(500); } catch (InterruptedException e) { e.printStackTrace(); } if(this.game.ileZapalek <= 3) { return this.game.ileZapalek; } else { return random.nextInt(3)+1; } } @Override public void run() { while(this.game.ileZapalek > 0) { if(this.game.ktory == this.id) { this.game.podnies(this.getIlosc(), this); } try { Player.sleep(1); } catch (InterruptedException e) { e.printStackTrace(); } } } }