class Reise { ... } class HashListe implements Iterable { void settInn (Reise r) { ... } } class Filter { Reise filtrer (Reise r) { if ( ?r er OK? ) return r; else return null; } } class Monitor { HashListe data = new HashListe(); Lock laas = ReentrantLock(); void settInn (Reise r) { laas.lock(); try { data.settInn(r); } finally { laas.unlock(); } } } class MonitorDemo { public static void main (String[] arg) { HashListe[] mangeReiser; : ?Fyller mangeReiser? Monitor mon = new Monitor(); Filter f = new Filter(); CountDownLatch barriere = new CountDownLatch(mangeReiser.length); class ParaFilter implements Runnable { HashListe mineReiser; ParaFilter (HashListe lst) { mineReiser = lst; } @Override public void run () { for (Reise r: mineReiser) { Reise rx = f.filter(r); if (rx != null) mon.leggTil(rx); } barriere.countDown(); } } for (int i = 0; i < mangeReiser.lenght; ++i) { ParaFilter pf = new ParaFilter(mangeReiser[i]); new Thread(pf).start(); } try { barriere.await(); } catch (InterruptedExpression e) {} for (Reise r: mon.data) { ... } } }