class Kaffedrikker implements Runnable { private Bord bord; private int id; public Kaffedrikker(Bord bord, int id) { this.bord = bord; this.id = id; } @Override public void run() { int antallDrukket = 0; try { String kaffe; while ((kaffe = bord.hentKaffe()) != null) { System.out.println("Kaffedrikker " + id + " drakk " + kaffe); antallDrukket++; } } catch (InterruptedException e) { Thread.currentThread().interrupt(); System.out.println("Kaffedrikker ble avbrutt"); } finally { System.out.println("Kaffedrikker " + id + " har drukket " + antallDrukket + " kaffer"); } } }