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

正文內(nèi)容

第07章-線程(編輯修改稿)

2024-10-22 19:04 本頁面
 

【文章內(nèi)容簡(jiǎn)介】 Subclassing Thread and Overriding run” ?繼承 Thread類 , 重寫 run()方法 2. “ Implementing the Runnable Interface” ?實(shí)現(xiàn) Runnable接口 ? 應(yīng)用場(chǎng)合 ? 當(dāng)所定義的類為一個(gè)子類時(shí),須利用 Runnable接口 線程的創(chuàng)建 12 第七章 線程 1. 概述 2. 線程的創(chuàng)建 ? 兩種方式 3. 線程的同步 1. synchronized 2. wait()/notifyAll()/notify() 4. 線程的生命周期 13 ? 獨(dú)立的 (independent)、異步的(asynchronous) 線程 ? 共享資源的訪問 ? 多個(gè)線程對(duì)同一資源進(jìn)行操作 (讀 /寫 ) ? 當(dāng)多個(gè)線程訪問同一數(shù)據(jù)項(xiàng)(如靜態(tài)字段、可全局訪問對(duì)象的實(shí)例字段或共享集合)時(shí),需要確保它們協(xié)調(diào)了對(duì)數(shù)據(jù)的訪問,這樣它們都可以看到數(shù)據(jù)的一致視圖,而且相互不會(huì)干擾另一方的更改 ? synchronized 關(guān)鍵詞 ? wait() / notify() / notifyAll() 方法 線程的同步 14 ? 線程同步 實(shí)例 線程的同步 public class CubbyHole { private int contents。 public int get() { return contents。 } public void put(int value) { contents = value。 } } public class Producer extends Thread { private CubbyHole cubbyhole。 public Producer(CubbyHole c) { cubbyhole = c。 } public void run() { for (int i = 0。 i 10。 i++) { (i)。 (Producer + put: + i)。 try { sleep((int)(() * 100))。 } catch (InterruptedException e) { } } } } public class Consumer extends Thread { private CubbyHole cubbyhole。 public Consumer(CubbyHole c) { cubbyhole = c。 } public void run() { int value = 0。 for (int i = 0。 i 10。 i++) { value = ()。 (Consumer “ + got: + value)。 } } } public class ProducerConsumerTest { public static void main(String[] args) { CubbyHole h = new CubbyHole()。 Producer p = new Producer(h)。 Consumer c = new Consumer(h)。 ()。 ()。 } } . . . Consumer got: 3 Producer put: 4 Producer put: 5 Consumer got: 5 . . . . . . Producer put: 4 Consumer got: 4 Consumer got: 4 Producer
點(diǎn)擊復(fù)制文檔內(nèi)容
環(huán)評(píng)公示相關(guān)推薦
文庫吧 www.dybbs8.com
備案圖片鄂ICP備17016276號(hào)-1