import java.util.concurrent.CountDownLatch; public class Task implements Runnable { private final CountDownLatch ferdigSignal; private Monitor fellesMonitor; public Task(CountDownLatch ferdig, Monitor monitor){ ferdigSignal = ferdig; fellesMonitor = monitor; } public void run(){ try{ gjorArbeid(); ferdigSignal.countDown(); } catch (InterruptedException ex){} } void gjorArbeid() throws InterruptedException{ System.out.println("Gj?r arbeid!"); fellesMonitor.leggTil(); } }