LockSupportDemo

package com.fh.interview;

import org.omg.PortableServer.THREAD_POLICY_ID;

import java.util.concurrent.locks.LockSupport;

/**
 * lockSupportDemo
 *
 * @author
 * @create 2018-06-02 下午3:56
 **/
public class LockSupportDemo {
    public static void main(String[] args) {
        Thread thread = new Thread(new Runnable() {
            @Override
            public void run() {
                LockSupport.park();
                System.out.println(Thread.currentThread().getName()+"条件满足");
            }
        });
        thread.start();
        try {
            Thread.sleep(3000);
        }catch (Exception e){
            e.printStackTrace();
        }
        LockSupport.unpark(thread);


    }
}

 

转载于:https://www.cnblogs.com/nihaofenghao/p/9125691.html

你可能感兴趣的:(LockSupportDemo)