freepeople性欧美熟妇, 色戒完整版无删减158分钟hd, 无码精品国产vα在线观看DVD, 丰满少妇伦精品无码专区在线观看,艾栗栗与纹身男宾馆3p50分钟,国产AV片在线观看,黑人与美女高潮,18岁女RAPPERDISSSUBS,国产手机在机看影片

正文內(nèi)容

第07章-線程-資料下載頁

2024-10-04 19:04本頁面
  

【正文】 void notifyAll() //喚醒所有等待的線程 public final void notify() //隨機喚醒一個等待的線程 The wait method relinquishes the lock held by the Consumer on the CubbyHole (thereby allowing the Producer to get the lock and update the CubbyHole) and then waits for notification from the Producer. 18 線程的同步 public class CubbyHole { private int contents。 private boolean available = false。 public synchronized int get() { while (available == false) { try { wait()。 //打開鎖,等候 Producer填值 } catch (InterruptedException e) { } } available = false。 notifyAll()。 return contents。 } public synchronized void put(int value) { while (available == true) { try { wait()。 //打開鎖,等候 Consumer取值 } catch (InterruptedException e) { } } contents = value。 available = true。 notifyAll()。 } } 線程 consumer get() 判斷當(dāng)前是否存有值 有 沒有 設(shè)置為空 喚醒 producer 取值 釋放鎖定 等待新值 線程 producer put() 判斷當(dāng)前是否存有值 有 沒有 釋放鎖定 等待取值 放值 設(shè)置為有 喚醒 consumer 19 第七章 線程 1. 概述 2. 線程的創(chuàng)建 ? 兩種方式 3. 線程的同步 1. synchronized 2. wait()/notifyAll()/notify() 4. 線程的生命周期 20 ? 線程啟動 1. new SimpleThread1(Jamaica).start()。 class SimpleThread1 extends Thread { … … } 2. SimpleThread2 a = new SimpleThread2(Jamaica)。 Thread thread = new Thread(a)。 ()。 class SimpleThread2 implements Runnable { … … } ? 線程停止 ? A thread dies naturally when the run method exits. 線程的生命周期 public void run() { int i = 0。 while (i 100) { i++。 (i = + i)。 } } 21 ? 進一步的學(xué)習(xí) ? Starvation (資源缺乏 ) ? Deadlock (死鎖 ) ? ThreadGroup (線程組 ) –同時對一組線程進行操作 ? 優(yōu)先權(quán) (Priorities) ? Daemon線程 線程 22 第七章 結(jié)束!
點擊復(fù)制文檔內(nèi)容
環(huán)評公示相關(guān)推薦
文庫吧 www.dybbs8.com
備案圖鄂ICP備17016276號-1