package com.elab.example.springbootdemo.demo;

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

/**
 * 唤醒
 *
 * @author ： liukx
 * @time ： 2019/8/14 - 14:47
 */
public class ConditionSignal implements Runnable {

    private Lock lock;
    private Condition condition;

    public ConditionSignal(Lock lock, Condition condition) {
        this.lock = lock;
        this.condition = condition;
    }

    @Override
    public void run() {
        try {
            this.lock.lock();
            System.out.println("BEGIN - ConditionSignal");
            condition.signal();
            System.out.println("END - ConditionSignal");
        } finally {
            this.lock.unlock();
        }
    }
}
