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

正文內(nèi)容

java語(yǔ)言程序設(shè)計(jì)基礎(chǔ)第2版線程ppt(參考版)

2024-10-21 15:05本頁(yè)面
  

【正文】 ()。 ()。 } } }。)。 print(在 run()中 取出 : 39。)。 print(在 run()中 取出 : 39。 (500)。 + obj + 39。 obj = ()。 } } }。)。 print(在 run()中 存入 :39。 2021/11/10 74 str = 多線程程序 。 + str + 39。 (str)。)。 print(在 run()中 存入 :39。 str = 用 Java。 Runnable runA = new Runnable() { public void run() { try { String str。 (name + : + msg)。 return obj。 notifyAll()。 slot = null。 print(在 takeOut()中 已通知 ,從等待返回 )。 while ( slot == null ) { print(在 takeOut()中 slot空 ,等待 )。 print(在 putIn()中 離開 )。 //將對(duì)象存入 slot print(在 putIn()中 填充 slot,通知所有線程 slot已滿 )。 print(在 putIn()中 已通知線程 ,從等待返回 )。 while ( slot != null ) { print(在 putIn()中 slot已占用 , 等待 )。 public CubbyHole() { slot = null。 }catch ( InterruptedException x ) { } threadPrint(中斷死鎖 ?)。 ()。 try { (1000)。 threadPrint(中斷 threadA)。 2021/11/10 67 try { (5000)。 Thread threadB = new Thread(runB, threadB)。 }catch ( InterruptedException x ) { } Runnable runB = new Runnable() { public void run() { (obj1)。 ()。 } }。 final DeadlockDemo obj2 = new DeadlockDemo(obj2)。 (threadName + : + msg)。 } public void print(String msg) { threadPrint(objID= + objID + + msg)。 // simulate some work here try { (500)。 print(離開 checkOther())。 }catch ( InterruptedException x ) { } 2021/11/10 64 print(在 check()中 + 調(diào)用 ())。 } public synchronized void check(DeadlockDemo other) { print(進(jìn)入 check())。 } } 2021/11/10 61 程序運(yùn)行結(jié)果 : 進(jìn)入 staticA() 進(jìn)入 staticB() 離開 staticA() 在 staticB()中 – 同步塊內(nèi)部 離開 staticB() 2021/11/10 62 避免死鎖 線程 A 線程 B 鎖 1 鎖 2 請(qǐng)求 請(qǐng)求 持有 持有 2021/11/10 63 死鎖 public class DeadlockDemo extends Object { private String objID。 Thread threadB = new Thread(runB, threadB)。 }catch ( InterruptedException x ) { } Runnable runB = new Runnable() { public void run() { ()。 ()。 } }。 }catch ( InterruptedException x ) { } } (離開 staticB())。 2021/11/10 59 synchronized ( ) { (在 staticB()中 同步塊內(nèi)部 )。 }catch ( InterruptedException x ) { } (離開 staticA())。 } catch ( InterruptedException x ) {// ignore} } } 2021/11/10 57 程序運(yùn)行結(jié)果 : threamA getNextSerialNum()=1001 threamB getNextSerialNum()=1002 threamC getNextSerialNum()=1003 threamD getNextSerialNum()=1004 2021/11/10 58 類層鎖的應(yīng)用 public class StaticBlock extends Object { public static synchronized void staticA() { (進(jìn)入 staticA())。 Thread threadD = new Thread(r, threadD)。 ()。 (500)。 Thread threadB = new Thread(r, threadB)。 ()。 } }。 (threadName + : + msg)。 return sn。 //為顯示明顯這里把延遲加長(zhǎng) try { (1000)。 } } 2021/11/10 53 程序運(yùn)行結(jié)果 : threadA: objID=obj1 – 輸入 doStuff() threadA: objID=obj1 – 在 doStuff()中 – 局部變量 num=10 threadB: objID=obj2 – 輸入 doStuff() threadB: objID=obj2 – 在 doStuff()中 – 局部 1變量 num=18 threadA: objID=obj1 – 離開 doStuff() threadA: objID=obj2 – 離開 doStuff() 2021/11/10 54 靜態(tài)變量同步 public class StaticSync extends Object { private static int nextSerialNum = 10001。 } public static void threadPrint(String msg) { String threadName = ().getName()。 }catch ( InterruptedException x ) { } print(離開 doStuff())。 print(在 doStuff()中 局部變量 num= + num)。 } 2021/11/10 51 public synchronized void doStuff(int val) { print(輸入 doStuff())。 Thread threadB = new Thread(runB,
點(diǎn)擊復(fù)制文檔內(nèi)容
教學(xué)課件相關(guān)推薦
文庫(kù)吧 www.dybbs8.com
備案圖鄂ICP備17016276號(hào)-1