[問題] 請教thread問題

看板C_Sharp作者 (smile)時間16年前 (2008/08/04 13:32), 編輯推噓0(000)
留言0則, 0人參與, 最新討論串1/5 (看更多)
小弟最近在寫C# 有用到thread 可是有些東西run出來結果會不如預期 比如說小弟自己寫一個有thread的程式 (如下) http://rafb.net/p/nY6LmJ63.html run出來的結果是 hello object 1 -- ContextID: 0 -- 1 hello object 1 -- ContextID: 0 -- 2 hello object 1 -- ContextID: 0 -- 3 hello object 1 -- ContextID: 0 -- 4 hello object 1 -- ContextID: 0 -- 6 hello object 1 -- ContextID: 0 -- 7 hello object 1 -- ContextID: 0 -- 8 hello object 1 -- ContextID: 0 -- 9 hello object 1 -- ContextID: 0 -- 10 hello object 1 -- ContextID: 0 -- 11 hello object 2 -- ContextID: 0 -- 5 hello object 2 -- ContextID: 0 -- 12 hello object 2 -- ContextID: 0 -- 13 hello object 2 -- ContextID: 0 -- 14 hello object 2 -- ContextID: 0 -- 15 hello object 2 -- ContextID: 0 -- 16 hello object 2 -- ContextID: 0 -- 17 hello object 2 -- ContextID: 0 -- 18 hello object 2 -- ContextID: 0 -- 19 hello object 2 -- ContextID: 0 -- 20 ====================================================== 小弟心中有個疑問... 為什麼會跑出回色那一個呢? 我都已經用lock了她跑出來還是沒有按照順序累加 請問板上精研c_sharp的程設先輩不吝指教 感恩~ -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 140.115.158.22
文章代碼(AID): #18bfHZo_ (C_Sharp)
文章代碼(AID): #18bfHZo_ (C_Sharp)