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; } @Override public void run() { while(this.game.ileZapalek > 0) { if(this.game.ktory == this.id) { try { Player.sleep(500); } catch (InterruptedException e) { e.printStackTrace(); } if(this.game.ileZapalek <= 3) { this.game.podnies(this.game.ileZapalek, this); } else { this.game.podnies(random.nextInt(3)+1, this); } } try { Player.sleep(1); } catch (InterruptedException e) { e.printStackTrace(); } } } }