@@ -0,0 +1,953 @@
+package ru.job4j.wait_and_other;%0A%0Aimport net.jcip.annotations.GuardedBy;%0Aimport net.jcip.annotations.ThreadSafe;%0A%0A/**%0A * Represent simple mechanism of thread locking.%0A *%0A * @author Alexander Bondarev(mailto:bondarew2507@gmail.com).%0A * @since 11.11.2017.%0A */%0A@ThreadSafe%0Apublic class Lock %7B%0A%0A    /**%0A     * Flag that signalised is resource locked or not.%0A     */%0A    @GuardedBy(%22this%22)%0A    private boolean locked = false;%0A%0A    /**%0A     * Locks some resource action from other threads if one turn on lock.%0A     * Other threads will wait until called unlock().%0A     *%0A     * @throws InterruptedException if interrupted while wait.%0A     */%0A    public synchronized void lock() throws InterruptedException %7B%0A        while (locked) %7B%0A            wait();%0A        %7D%0A        locked = true;%0A    %7D%0A%0A    /**%0A     * Turn off lock and send signal someone threads awake.%0A     */%0A    public synchronized void unlock() %7B%0A        locked = false;%0A        notify();%0A    %7D%0A%7D%0A

Implement own Lock mechanism using synchronized, wait and notify. Task #1100