package dk.itu.oop.lecture10; class Lecture10{ public static void main(String args[]) { SomeRessource ressource = new SomeRessource(); ResultObject res = ressource.getSomething(); try{ Thread.sleep(1200);}catch(Exception e){}; System.out.println("weee..."); System.out.println(res.result()); } } interface ResultObject { Object result(); } class SomeResult implements ResultObject,Runnable { Object result; SomeResult(){ new Thread(this).start(); } public synchronized void run(){ try{Thread.sleep(1000); }catch(Exception e){}; result = "Got it"; notifyAll(); } public synchronized Object result(){ while ( result == null) try{wait();}catch(Exception e){}; return result; } } class SomeRessource { ResultObject getSomething(){ return new SomeResult();} }