import java.util.concurrent.locks.ReentrantLock; import java.util.concurrent.locks.Condition; import java.util.concurrent.locks.Lock; class Bankkonto { int saldo = 0; Lock l?s = new ReentrantLock(); Condition ikkeTomt = l?s.newCondition(); public void settInn(int bel?p){ l?s.lock(); try{ saldo += bel?p; ikkeTomt.signalAll(); }finally{ l?s.unlock(); } } public void taUt(int bel?p) throws InterruptedException{ l?s.lock(); try{ while (saldo < bel?p){ ikkeTomt.await(); } saldo -= bel?p; //System.out.println("Tok ut "+bel?p+", ny saldo: "+saldo); }finally{ l?s.unlock(); } } }