package reentrantlock;

import java.util.concurrent.locks.Condition;
import java.util.concurrent.locks.ReentrantLock;

public class ReenterLockCondition implements Runnable {
    private static ReentrantLock lock = new ReentrantLock();
    private static Condition condition = lock.newCondition();

    @Override
    public void run() {
        try {
            lock.lock();
            System.out.println("locking...");
            condition.await();
            System.out.println("going on...");
        } catch (InterruptedException e) {
            e.printStackTrace();
        } finally {
            lock.unlock();
        }
    }

    public static void main(String[] args) throws InterruptedException {
        ReenterLockCondition reenterLockCondition=new ReenterLockCondition();

        Thread thread=new Thread(reenterLockCondition);
        thread.start();

        Thread.sleep(1000);

        lock.lock();
        condition.signal();
        lock.unlock();

    }
}

@@ -928,48 +928,201 @@
     
-condition.signal();%0A        lock.unlock(
+System.out.println(%22condition get lock...%22);%0A        condition.signal();%0A        System.out.println(%22condition send signal...%22);%0A        lock.unlock();%0A        System.out.println(%22release lock%22
 );%0A%0A

add reentrantLock 重入锁 Condition