package dk.itu.oop.lecture10; class Exercise34{ 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()); } } abstract class ResultObject implements Runnable{ Object result; ResultObject(){ new Thread(this).start(); } final public synchronized void run(){ result = computeResult(); try{Thread.sleep(1000); }catch(Exception e){}; notifyAll(); } final public synchronized Object result(){ while ( result == null) try{wait();}catch(Exception e){}; return result; } protected abstract Object computeResult(); } class SomeResult extends ResultObject{ protected Object computeResult(){ return "Got it";} } class SomeRessource { ResultObject getSomething(){ return new SomeResult();} }