MyTask.java

package ch.hslu.exercises.sw06.ex1;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public final class MyTask implements Runnable {
    private static final Logger LOG = LoggerFactory.getLogger(MyTask.class);
    private final Object lock;

    public MyTask(final Object lock) {
        this.lock = lock;
    }

    @Override
    public void run() {
        synchronized (lock) {
            LOG.info("warten...");
            try {
                lock.wait();
            } catch (InterruptedException ex) {
                return;
            }
        }
        LOG.info("...aufgewacht");
    }
}