Java threads use --LockSupport

Original: Reprinted indicate the original address https://www.cnblogs.com/fanerwei222/p/11871805.html

Java threads use --LockSupport

public  static  void main (String [] args) {
     / ** 
     * blocks the current thread, suspend scheduling, interrupt response 
     * to acquire the lock failure has also been blocked, until I got the lock 
     * / 
    LockSupport.park (); 
    / ** 
     * blocking current threads, timeout automatically released 
     * / 
    LockSupport.parkNanos ( 0 );
     / ** 
     * blocks the current thread, the timeout is automatically released 
     * / 
    LockSupport.parkUntil ( 0 );
     / ** 
     * release the current thread 
     * / 
    LockSupport.unpark ( null );
     / ** 
     * LockSupport.park () this method is called 
     * / 
    . Unsafe.getUnsafe () Park ( to true , 0L ); 
}

 

Guess you like

Origin www.cnblogs.com/fanerwei222/p/11871805.html