Re: [閒聊] ignore_user_abort()

看板PHP作者 (O⊥M)時間18年前 (2007/05/19 10:51), 編輯推噓1(100)
留言1則, 1人參與, 最新討論串2/3 (看更多)
※ 引述《buganini (霸格尼尼)》之銘言: : 然後這個php沒執行完就被中斷了 : 所以弄出jpg檔的動作沒做到 : 後來用以下兩行解決 : ignore_user_abort(true); : set_time_limit(0); : ignore_user_abort()可以讓php不會被中斷 : 於是一系列動作都會乖乖的執行完 剛突然想到,這是不是可以用來模擬 threading ? 假設寫了一個 thread.php 然後分別執行 n 次, 那麼應該就會有 n 個 thread.php 在執行... (所以實際上應該是 multi-process programming :P) <?php //thread.php ignore_user_abort(true); set_time_limit(0); while(1) { // 無限迴圈 // do something ... } ?> sync 的部分可以用資料庫讀寫同一個欄位、或是讀寫同一個檔案, 但是 sleep() / wakeup() 之類的功能該怎麼達成勒? -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 140.119.199.121 ※ 編輯: foxzgerald 來自: 140.119.199.121 (05/19 10:57)

05/19 19:16, , 1F
差多了,thread、fork 跟無窮迴圈是不同的架構..
05/19 19:16, 1F
文章代碼(AID): #16JcP9P4 (PHP)
討論串 (同標題文章)
文章代碼(AID): #16JcP9P4 (PHP)