import java.io.File; import java.util.Scanner; public class SoknadsBehandler implements Runnable{ private File fil; private Monitor monitor; public SoknadsBehandler(File fil, Monitor monitor){ this.fil = fil; this.monitor = monitor; } @Override public void run(){ Scanner scanner = null; try{ scanner = new Scanner(fil); }catch(Exception e){ System.out.println(e); return; } while(scanner.hasNextLine()){ String[] linje = scanner.nextLine().split(" "); boolean oslo = true; if(linje[1].equals("nei")){ oslo = false; } int alder = Integer.parseInt(linje[2]); boolean rikeForeldre = true; if(linje[3].equals("nei")){ rikeForeldre = false; } monitor.leggTilSoknad(new Soknad(linje[0], Soknad.prioritering(oslo, alder, rikeForeldre))); try{ Thread.sleep(10000); }catch(Exception e){ System.out.println(e); } } //signaliserer til monitoren at denne tr?den er ferdig med ? jobbe monitor.leggTilSoknad(null); } }