程序:執行緒
執行緒的組成:
多執行緒:
需要繼承thread或者實現runnable3、生產者,消費者的問題執行緒的建立
兩種方法的區別
執行緒的命名:class
test
extends
thread
public
static
void
main
(string[
] args)
}
呼叫start()方法與直接呼叫run()方法的區別
執行緒的優先順序priority
執行緒的常用方法
執行緒的狀態
執行緒的同步
synchronized關鍵字, ),執行到這個方法時,都要檢查有沒有其它執行緒b(或者c、 d等)正在用這個方法(或者該類的其他同步方法),有的話要等正在使用synchronized方法的執行緒b(或者c 、d)執行完這個方法後再執行此執行緒a,沒有的話,鎖定呼叫者,然後直接執行。
當乙個執行緒訪問乙個synchronized(this)同步**塊時,其他synchronized(this)同步**塊同樣被鎖定
public
class
runthread
implements
runnable
synchronized
(this
)catch
(interruptedexception e)
system.out.
println
(thread.
currentthread()
.getname()
+"跑了十公尺");
} length = length -
100;
system.out.
println
(thread.
currentthread()
.getname()
+"跑了一百公尺 ,換下一人");
system.out.
println
("還剩下:"
+(length)
+"公尺");
return;}
}public
class
test
}
主要涉及到是兩個object之中的方法:void wite(); 使執行緒進入等待的狀態,直到執行緒被喚醒
void notfiy(); 喚醒執行緒 ,是隨機喚醒
public
class
compublic
void
sethost
(string host)
public string getdisplay()
public
void
setdisplay
(string display)
public
com(string host , string display)
public com (
)public string tostring()
}public
class
consumer
implements
runnable
public
consumer
(com com)
public
void
run(
)catch
(interruptedexception e)
}else}}
}}public
class
proimplements
runnable
public
pro(com com)
public
void
run(
)catch
(interruptedexception e)
}else
else}}
}}}public
class
supermarket
}
IP基礎知識梳理
離開學校後看書少了很多,發現掌握的ip知識不是很牢,所以在這裡也稍稍梳理下,感覺語言也沒書本上詳盡 完全是筆記形式,望讀者勿噴 ip層 網路層也叫internet層,負責將分組報文從源端傳送到目的端。作用 tcp ip模型 參考 即整個網路上傳送的二進位制資料總結為如下格式 後的鏈路配置為trunk...
jQuery基礎知識梳理
語法 jquery語法是為html元素的選取編制的,可以對元素執行某些操作。基礎語法 selector action 美元符號定義jquery 選擇符 selector 查詢 和 查詢 html元素 jquery的action 執行對元素的操作 文件就緒函式 為防止文件在完全載入之前裕興jquery...
Spring基礎知識梳理
1 spring概要 spring現在主要是一站式服務,spring core container是 其中最重要的元件,一般與其他框架一起用。spring容器最重要的作用?是管理bean,spring容器中的全部物件都是bean。spring通過什麼來管理bean?xml檔案 spring的底層會執...