[JAVA]《Java 核心技术》(四)多线程

1. Thread.sleep(long millis)
休眠给定的毫秒数
 
2.Rnnable接口
run()
方法
 
或者extends Thread
run()
 
start()方法
 
3.
join()
等待终止指定的线程
stop()
已过时的方法终止线程。
suspend()
resume()
 
setPriority
 
yield
 
setDaemon();守护线程
 
4  条件
使得 已经获得锁对象,时候发现条件不满足时,则先放弃锁,阻塞,让别的对象获得锁并
来激活这个条件满足。
 
5 synchronized
在方法体之前加上这个修饰
public synchronized void method(){
     // method body
}
 
等价于
public void method(){
     this.intrinsicLock.lock();
     tyr{
          method body
     }
     finally{
          this.intrinsicLck.unlock();
     }
}
 
synchronized有一个锁,并且该锁有一个内部条件
 
synchronized还可以放在方法体内 对某个变量
synchronized(obj){
}
 
6 volatile
原文地址:https://www.cnblogs.com/akingseu/p/3452573.html