SlideShare a Scribd company logo
作業系統作業
-執行緒
D1024241042 莊英基
畫面1
1.Thread() – ThreadExample1
執行結果
 Constrctor沒有參數,Thread()產生的Thread,進入點為
run()。當run()結束時,這個執行緒也就結束了,和mian()結
束有相同效果。
 1.第4行,覆蓋執行緒的運行。
 2.第5行,印出這裡是執行緒的起點。
 3.第6行,無限循環印出訊息。
 4.第7行,印出User Created Thread。
 5.第11行,產生Thread物件。
 6.第12行,開始執行 t.run()。
 7.第13行,進入無限循環印出訊息。
 8.第14行,印出Main Thread。
 執行以上程式後,螢幕會持續印出User Created Thread 或
Main Thread。
解釋
畫面2
2.Thread(Runnable) – ThreadExample2
執行結果
 需要一個Runnable物件當參數,Thread(Runnable)產生的
Thread,進入點為Runnable物件裡的run()。當run()結束時,
這個執行緒也就結束了,與main()結束有相同的效果。
 1.第4行,執行Runnable的運行。
 2.第5行,印出這裡是執行緒的起點。
 3.第6行,無限循環印出訊息。
 4.第7行,印出User Created Thread。
 5.第11行,產生Thread物件。
 6.第12行,開始執行 Runnable.run()。
 7.第13行,進入無限循環印出訊息。
 8.第14行,印出Main Thread。
 執行以上程式後,螢幕會持續印出User Created Thread 或
Main Thread。
解釋

More Related Content

Viewers also liked

Asset Allocation
Asset AllocationAsset Allocation
Asset Allocation
Ashkan Karbalaeifar
 
Rami-okasha-CV 2
Rami-okasha-CV 2Rami-okasha-CV 2
Rami-okasha-CV 2
Rami Okasha
 
Power_Point_Presentation_ISSC458_Intindolo
Power_Point_Presentation_ISSC458_IntindoloPower_Point_Presentation_ISSC458_Intindolo
Power_Point_Presentation_ISSC458_Intindolo
John Intindolo
 
Life Under the Big Tent-Making Festivals Work
Life Under the Big Tent-Making Festivals WorkLife Under the Big Tent-Making Festivals Work
Life Under the Big Tent-Making Festivals Work
John Prue
 
Om0012 supply chain management
Om0012 supply chain managementOm0012 supply chain management
Om0012 supply chain management
consult4solutions
 
WDM RESUME 2016
WDM RESUME 2016WDM RESUME 2016
WDM RESUME 2016
William Mueller
 
Tinh toan ket_cau_thep(_nguyen_van_yen)_
Tinh toan ket_cau_thep(_nguyen_van_yen)_Tinh toan ket_cau_thep(_nguyen_van_yen)_
Tinh toan ket_cau_thep(_nguyen_van_yen)_
Tuấn Vinh Huỳnh
 
Sanjay Gupta Profile(new)
Sanjay Gupta Profile(new)Sanjay Gupta Profile(new)
Sanjay Gupta Profile(new)
Sanjay Gupta
 
Memórias secundarias 2
Memórias secundarias 2Memórias secundarias 2
Memórias secundarias 2
ananiasdoamaral
 
Video editing tips - Colin J Smith
Video editing tips - Colin J SmithVideo editing tips - Colin J Smith
Video editing tips - Colin J Smith
Dr Colin Smith
 
Tarea nº 3 actividades ii
Tarea nº 3 actividades iiTarea nº 3 actividades ii
Tarea nº 3 actividades ii
Alejandro Moises Espiritu Rojas
 
Acms el-secretario-de-iglesia
Acms el-secretario-de-iglesiaAcms el-secretario-de-iglesia
Acms el-secretario-de-iglesia
Henry Alexander Salgado Martinez
 
Questionnaire analysis 1
Questionnaire analysis 1Questionnaire analysis 1
Questionnaire analysis 1
sarahlouise12
 
Prashant Resume-22.11.15
Prashant Resume-22.11.15Prashant Resume-22.11.15
Prashant Resume-22.11.15
Prashant Asati
 

Viewers also liked (14)

Asset Allocation
Asset AllocationAsset Allocation
Asset Allocation
 
Rami-okasha-CV 2
Rami-okasha-CV 2Rami-okasha-CV 2
Rami-okasha-CV 2
 
Power_Point_Presentation_ISSC458_Intindolo
Power_Point_Presentation_ISSC458_IntindoloPower_Point_Presentation_ISSC458_Intindolo
Power_Point_Presentation_ISSC458_Intindolo
 
Life Under the Big Tent-Making Festivals Work
Life Under the Big Tent-Making Festivals WorkLife Under the Big Tent-Making Festivals Work
Life Under the Big Tent-Making Festivals Work
 
Om0012 supply chain management
Om0012 supply chain managementOm0012 supply chain management
Om0012 supply chain management
 
WDM RESUME 2016
WDM RESUME 2016WDM RESUME 2016
WDM RESUME 2016
 
Tinh toan ket_cau_thep(_nguyen_van_yen)_
Tinh toan ket_cau_thep(_nguyen_van_yen)_Tinh toan ket_cau_thep(_nguyen_van_yen)_
Tinh toan ket_cau_thep(_nguyen_van_yen)_
 
Sanjay Gupta Profile(new)
Sanjay Gupta Profile(new)Sanjay Gupta Profile(new)
Sanjay Gupta Profile(new)
 
Memórias secundarias 2
Memórias secundarias 2Memórias secundarias 2
Memórias secundarias 2
 
Video editing tips - Colin J Smith
Video editing tips - Colin J SmithVideo editing tips - Colin J Smith
Video editing tips - Colin J Smith
 
Tarea nº 3 actividades ii
Tarea nº 3 actividades iiTarea nº 3 actividades ii
Tarea nº 3 actividades ii
 
Acms el-secretario-de-iglesia
Acms el-secretario-de-iglesiaAcms el-secretario-de-iglesia
Acms el-secretario-de-iglesia
 
Questionnaire analysis 1
Questionnaire analysis 1Questionnaire analysis 1
Questionnaire analysis 1
 
Prashant Resume-22.11.15
Prashant Resume-22.11.15Prashant Resume-22.11.15
Prashant Resume-22.11.15
 

作業系統作業莊英基