SlideShare a Scribd company logo
作業系統作業
執行緒
資三A D1024241027 謝宜玲
第一個畫面
1.Thread() – ThreadExample1
執行結果
D1024241027
Constrctor沒有參數,Thread()產生的Thread,進入點是run()。
那麼,當run()結束的時候,這個執行緒也就結束了,和mian()結束
有相同的效果。
第4行,表示覆蓋了執行緒的運行。
第5行,表示要印出的執行緒的起點。
第6行,表示無限循環印出的訊息。
第7行,表示要印出User Created Thread。
第11行,表示產生Thread物件。
第12行,表示要開始執行 t.run()。
第13行,表示無限循環印出的訊息。
第14行,表示要印出Main Thread D1024241027謝宜玲。
執行以上的程式之後,螢幕上會持續的印出User Created Thread 或
Main Thread D1024241027謝宜玲的結果。
解釋
第二個畫面
2.Thread(Runnable) – ThreadExample2
執行結果
D1024241027
我們需要一個Runnable物件來當參數,Thread(Runnable)產生的
Thread,進入點是Runnable物件裡的run()。
當run()結束的時候,這個執行緒也就結束了,與main()結束有相同
的效果。
第4行,表示執行Runnable的運行。
第5行,表示要印出的執行緒的起點。
第6行,表示無限循環印出的訊息。
第7行,表示要印出User Created Thread。
第11行,表示產生Thread物件。
第12行,表示要開始執行 Runnable.run()。
第13行,表示無限循環印出的訊息。
第14行,表示要印出Main Thread D1024241027謝宜玲。
執行以上的程式之後,螢幕上會持續印出User Created Thread 或
Main Thread D1024241027謝宜玲的結果。
解釋

More Related Content

PPTX
D1024241027
PPTX
作業系統作業莊英基
PPTX
D102424126陳萱
PPTX
作業系統 執行緒
PPTX
Salazar Autobiography Presentation
PPTX
Joy Shin Autobiography
PPTX
Salazar Presentation Autobiography
PPTX
Wilson atuobiography
D1024241027
作業系統作業莊英基
D102424126陳萱
作業系統 執行緒
Salazar Autobiography Presentation
Joy Shin Autobiography
Salazar Presentation Autobiography
Wilson atuobiography

Viewers also liked (8)

PPTX
Presentacion Informatica3
PPTX
Hansele Autobiography powerpoint
PPTX
My autobiography
DOCX
An Example Of An Autobiography
PDF
How to stand out online
PDF
Your Speech is Toxic
PDF
Great Speakers Tell Stories
PDF
SMOKE - The Convenient Truth [1st place Worlds Best Presentation Contest] by ...
Presentacion Informatica3
Hansele Autobiography powerpoint
My autobiography
An Example Of An Autobiography
How to stand out online
Your Speech is Toxic
Great Speakers Tell Stories
SMOKE - The Convenient Truth [1st place Worlds Best Presentation Contest] by ...
Ad

D1024241027