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);


    }
}

 

posted @ 2018-06-02 16:09  默默行走  阅读(94)  评论(0编辑  收藏  举报